From 02df5f3841633165107ab54932e7f9c1def5a692 Mon Sep 17 00:00:00 2001 From: Jordan Phillips Date: Mon, 15 Apr 2024 16:20:52 +1000 Subject: [PATCH] ci: export and store graphql schema + nextjs caching --- .github/actions/cache/action.yml | 1 - .github/actions/schema/action.yml | 19 ++++++++++++ .github/actions/setup/action.yml | 1 - .github/workflows/pr-title.yml | 2 -- .github/workflows/pull-request.yml | 47 +++++++++++++++++------------- .github/workflows/push.yml | 31 ++++++++++++-------- 6 files changed, 64 insertions(+), 37 deletions(-) create mode 100644 .github/actions/schema/action.yml diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml index 860f94a5..ebbd1994 100644 --- a/.github/actions/cache/action.yml +++ b/.github/actions/cache/action.yml @@ -1,5 +1,4 @@ name: "๐Ÿ”บ๏ธ " -author: "PHILLIPS71" runs: using: "composite" diff --git a/.github/actions/schema/action.yml b/.github/actions/schema/action.yml new file mode 100644 index 00000000..e5684701 --- /dev/null +++ b/.github/actions/schema/action.yml @@ -0,0 +1,19 @@ +name: "๐Ÿ“„ " + +inputs: + working-directory: + required: true + +runs: + using: "composite" + steps: + - name: "๐Ÿ“„ Build GraphQL Schema" + run: dotnet run -- schema export --output schema.graphql + working-directory: ${{ inputs.working-directory }} + + - name: "๐Ÿ“„ Upload GraphQL Schema" + uses: actions/upload-artifact@v4 + with: + name: schema-${{ github.run_number }}.graphql + path: ${{ inputs.working-directory }}/schema.graphql + retention-days: 1 diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 387043e6..71f3b75d 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -1,5 +1,4 @@ name: "๐Ÿ’ฝ๏ธ " -author: "PHILLIPS71" inputs: node-version: diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml index 870aa534..cb003cca 100644 --- a/.github/workflows/pr-title.yml +++ b/.github/workflows/pr-title.yml @@ -2,8 +2,6 @@ name: "๐Ÿ“ PR Title" on: pull_request_target: - branches: - - main jobs: main: diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9162f308..a75e709f 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,9 +1,7 @@ -name: "โ–ถ๏ธ Pull Request" +name: "๐Ÿ”€ Pull Request" on: pull_request_target: - branches: - - main concurrency: group: pull-request-${{ github.event.pull_request.number }} @@ -44,6 +42,11 @@ jobs: run: dotnet test --verbosity quiet working-directory: ./src/Service.Dashboard + - name: "โฌ†๏ธ GraphQL Schema (upload)" + uses: ./.github/actions/schema + with: + working-directory: src/Service.Dashboard + encoder: name: "๐Ÿ‘ท๏ธ CI (Encoder)" timeout-minutes: 20 @@ -81,29 +84,31 @@ jobs: run: | pnpm install --frozen-lockfile - - name: "๐Ÿ”บ๏ธ Cache" + - name: "๐Ÿ”บ๏ธ Cache (pnpm)" uses: ./.github/actions/cache + - name: "โฌ‡๏ธ GraphQL Schema (download)" + uses: actions/download-artifact@v4 + with: + name: schema-${{ github.run_number }}.graphql + path: ./app + - name: "๐Ÿ—๏ธ Build" working-directory: ./app shell: bash run: | pnpm run build - - name: "๐Ÿšจ๏ธ Lint" - working-directory: ./app - shell: bash - run: | - pnpm run lint - - - name: "๐Ÿฆบ Type Check" - working-directory: ./app - shell: bash - run: | - pnpm run type-check - - - name: "๐Ÿงช Test" - working-directory: ./app - shell: bash - run: | - pnpm run test + - name: "๐Ÿ”บ๏ธ Cache (nextjs)" + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/app/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- + + # - name: "๐Ÿงช Test" + # working-directory: ./app + # shell: bash + # run: | + # pnpm run test diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 66e4defb..93fa221e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -42,6 +42,11 @@ jobs: run: dotnet test --verbosity quiet working-directory: ./src/Service.Dashboard + - name: "โฌ†๏ธ GraphQL Schema (upload)" + uses: ./.github/actions/schema + with: + working-directory: src/Service.Dashboard + encoder: name: "๐Ÿ‘ท๏ธ CI (Encoder)" timeout-minutes: 20 @@ -79,26 +84,28 @@ jobs: run: | pnpm install --frozen-lockfile - - name: "๐Ÿ”บ๏ธ Cache" + - name: "๐Ÿ”บ๏ธ Cache (pnpm)" uses: ./.github/actions/cache + - name: "โฌ‡๏ธ GraphQL Schema (download)" + uses: actions/download-artifact@v4 + with: + name: schema-${{ github.run_number }}.graphql + path: ./app + - name: "๐Ÿ—๏ธ Build" working-directory: ./app shell: bash run: | pnpm run build - - name: "๐Ÿšจ๏ธ Lint" - working-directory: ./app - shell: bash - run: | - pnpm run lint - - - name: "๐Ÿฆบ Type Check" - working-directory: ./app - shell: bash - run: | - pnpm run type-check + - name: "๐Ÿ”บ๏ธ Cache (nextjs)" + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/app/.next/cache + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} + restore-keys: | + ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- - name: "๐Ÿงช Test" working-directory: ./app