Skip to content

Commit

Permalink
Merge pull request #1 from tuatmcc/feat/ci
Browse files Browse the repository at this point in the history
feat/ci
  • Loading branch information
OJII3 authored Dec 13, 2024
2 parents a01dd0c + c10b1c3 commit 51eb38f
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 18 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
KIBELA_API_URL=
KIBELA_ACCESS_TOKEN=
102 changes: 102 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Check
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Setup | Checkout
uses: actions/checkout@v4

- name: Setup | Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup | Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm

- name: Setup | Install Dependencies
run: pnpm install --frozen-lockfile

- name: Run | Lint
run: pnpm run lint

typecheck:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Setup | Checkout
uses: actions/checkout@v4

- name: Setup | Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup | Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm

- name: Setup | Install Dependencies
run: pnpm install --frozen-lockfile

- name: Run | Type Check
run: pnpm run typecheck

check-schema:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Setup | Checkout
uses: actions/checkout@v4

- name: Setup | Install pnpm
uses: pnpm/action-setup@v4
with:
run_install: false

- name: Setup | Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm

- name: Setup | Install Dependencies
run: pnpm install --frozen-lockfile

- name: Setup | Generate Type for GraphQL
run: pnpm codegen

- name: Run | Check Diff
run: |
fail=0
# Check Type
if [ "$(git diff --ignore-space-at-eol --text src/graphql | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes in type definitions. See status below:"
git diff --ignore-space-at-eol --text app/libs/database.ts
fail=1
fi
if [ "$fail" -gt "0" ]; then
echo "Detected uncommitted changes in schema definitions. Please commit the changes before pushing."
exit 1
fi
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact = true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.10.0
4 changes: 2 additions & 2 deletions graphql/query.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
query GetAllPosts {
folderFromPath(path: "https://tuatmcc.kibe.la/folders/3754") {
query GetAllPosts($folderPath: String!) {
folderFromPath(path: $folderPath) {
id
name
notes(first: 1000) {
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"start": "next start",
"lint": "biome check .",
"fmt": "biome check . --write",
"typecheck": "tsc --noEmit",
"codegen": "graphql-codegen --config codegen.ts",
"get-graphql-schema": "get-graphql-schema"
},
Expand Down Expand Up @@ -35,5 +36,6 @@
"postcss": "^8",
"tailwindcss": "^3.4.1",
"typescript": "^5"
}
},
"packageManager": "[email protected]"
}
26 changes: 17 additions & 9 deletions src/app/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@ import { GetAllPostsDocument, GetPostDocument } from "@/graphql/request";
import type { GetAllPostsQuery, GetPostQuery } from "@/graphql/types";
import { query } from "@/lib/client";

export async function generateStaticParams() {
export async function generateStaticParams(): Promise<{ id: string }[]> {
const {
data: {
folderFromPath: { notes },
},
error,
} = await query<GetAllPostsQuery>({
query: GetAllPostsDocument,
variables: {
folderPath: "https://tuatmcc.kibe.la/folders/3754",
},
});
await new Promise((resolve) => setTimeout(resolve, 100));

if (error) {
if (error || !notes.edges?.length) {
throw error;
}

return notes.edges
?.map((edge) => ({
id: edge?.node?.id,
}))
.filter((id) => Boolean(id));
return notes.edges.flatMap((edge) => {
if (!edge?.node?.id) return [];
return { id: edge.node.id };
});
}

export default async function Blog({ params }: { params: { id: string } }) {
const { id } = params;
export default async function Blog({
params,
}: {
params: Promise<{ id: string }>;
}) {
const { id } = await params;

const { data, error } = await query<GetPostQuery>({
query: GetPostDocument,
variables: { id },
});
await new Promise((resolve) => setTimeout(resolve, 100));

if (error) {
throw error;
Expand Down
4 changes: 4 additions & 0 deletions src/app/_components/HomeContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ export const HomeContainer = async () => {
},
} = await query<GetAllPostsQuery>({
query: GetAllPostsDocument,
variables: {
folderPath: "https://tuatmcc.kibe.la/folders/3754",
},
});
if (error) {
throw error;
}
await new Promise((resolve) => setTimeout(resolve, 100));

return (
<main className="container mx-auto px-4 py-8">
Expand Down
1 change: 0 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { Metadata } from "next";
import localFont from "next/font/local";
import "./globals.css";
import { Provider } from "@urql/next";

const geistSans = localFont({
src: "./fonts/GeistVF.woff",
Expand Down
6 changes: 3 additions & 3 deletions src/graphql/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import gql from 'graphql-tag';
type GraphQLClientRequestHeaders = RequestOptions['requestHeaders'];

export const GetAllPostsDocument = gql`
query GetAllPosts {
folderFromPath(path: "https://tuatmcc.kibe.la/folders/3754") {
query GetAllPosts($folderPath: String!) {
folderFromPath(path: $folderPath) {
id
name
notes(first: 1000) {
Expand Down Expand Up @@ -41,7 +41,7 @@ const defaultWrapper: SdkFunctionWrapper = (action, _operationName, _operationTy

export function getSdk(client: GraphQLClient, withWrapper: SdkFunctionWrapper = defaultWrapper) {
return {
GetAllPosts(variables?: Types.GetAllPostsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<Types.GetAllPostsQuery> {
GetAllPosts(variables: Types.GetAllPostsQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<Types.GetAllPostsQuery> {
return withWrapper((wrappedRequestHeaders) => client.request<Types.GetAllPostsQuery>(GetAllPostsDocument, variables, {...requestHeaders, ...wrappedRequestHeaders}), 'GetAllPosts', 'query', variables);
},
GetPost(variables: Types.GetPostQueryVariables, requestHeaders?: GraphQLClientRequestHeaders): Promise<Types.GetPostQuery> {
Expand Down
4 changes: 3 additions & 1 deletion src/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3617,7 +3617,9 @@ export enum WatchState {
WatchNoteUpdate = 'WATCH_NOTE_UPDATE'
}

export type GetAllPostsQueryVariables = Exact<{ [key: string]: never; }>;
export type GetAllPostsQueryVariables = Exact<{
folderPath: Scalars['String']['input'];
}>;


export type GetAllPostsQuery = { readonly __typename?: 'Query', readonly folderFromPath: { readonly __typename?: 'Folder', readonly id: string, readonly name: string, readonly notes: { readonly __typename?: 'NoteConnection', readonly totalCount: number, readonly edges?: ReadonlyArray<{ readonly __typename?: 'NoteEdge', readonly node?: { readonly __typename?: 'Note', readonly id: string, readonly title: string, readonly createdAt: any } | null } | null> | null } } };
Expand Down
2 changes: 1 addition & 1 deletion src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const { getClient, query, PreloadQuery } = registerApolloClient(() => {
return new ApolloClient({
cache: new InMemoryCache(),
link: new HttpLink({
uri: "https://tuatmcc.kibe.la/api/v1",
uri: process.env.KIBELA_API_URL,
headers: {
Authorization: `Bearer ${process.env.KIBELA_ACCESS_TOKEN}`,
},
Expand Down

0 comments on commit 51eb38f

Please sign in to comment.