From e0c94bc97a4cbed0237309794ec7fdf0ef403a99 Mon Sep 17 00:00:00 2001 From: SimeonC <1085899+SimeonC@users.noreply.github.com> Date: Thu, 28 Sep 2023 17:41:06 +0900 Subject: [PATCH] ci: fix nx branch setup * properly cache the result of tests so the same junit file is output (requires vite config and nx config) * cache build outputs so they can be restored See https://github.com/tablecheck/tablecheck-react-system/actions/runs/6336490202/job/17209658997 --- .github/setup/action.yml | 10 ++++++++-- .github/workflows/docs.yml | 2 +- .github/workflows/pull_requests.yml | 14 +++----------- .github/workflows/release.yml | 2 ++ nx.json | 5 +++-- packages/eslint-plugin/project.json | 2 ++ packages/eslint-plugin/vite.config.ts | 1 + 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/setup/action.yml b/.github/setup/action.yml index 44ddb4a5..fb6e267f 100644 --- a/.github/setup/action.yml +++ b/.github/setup/action.yml @@ -19,7 +19,7 @@ runs: - name: Read .nvmrc shell: bash id: nvm - run: echo "::set-output name=nvmrc::$(cat .nvmrc)" + run: echo "nvmrc=$(cat .nvmrc)" >> $GITHUB_OUTPUT - name: Setup Node.js uses: actions/setup-node@v2 @@ -27,8 +27,14 @@ runs: node-version: ${{ steps.nvm.outputs.nvmrc }} cache: npm - - name: Setup branch for NX + - name: Setup branch for NX (main) shell: bash + if: github.ref == 'refs/head/main' + run: git branch -u origin/main main + + - name: Setup branch for NX (!main) + shell: bash + if: github.ref != 'refs/head/main' run: git branch --track main origin/main - name: Install without scripts 🔧 diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 57a658ef..dbfa971e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -14,7 +14,7 @@ jobs: - name: Read .nvmrc id: nvm - run: echo ::set-output name=nvmrc::$(cat .nvmrc) + run: echo "nvmrc=$(cat .nvmrc)" >> $GITHUB_OUTPUT - name: Setup Node.js uses: actions/setup-node@v2 diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 16c319d6..05bed82f 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -10,16 +10,7 @@ concurrency: cancel-in-progress: true jobs: - setup: - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v2 - - - uses: ./.github/setup - checks: - needs: [setup] runs-on: ubuntu-latest steps: - name: Checkout 🛎️ @@ -40,7 +31,6 @@ jobs: OSSI_TOKEN: ${{ secrets.OSSI_TOKEN }} test: - needs: [setup] runs-on: ubuntu-latest steps: - name: Checkout 🛎️ @@ -55,7 +45,7 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v1 if: always() with: - files: junit/**/*.xml + files: coverage/**/*.junit.xml release: runs-on: ubuntu-latest @@ -64,6 +54,8 @@ jobs: steps: - name: Checkout 🛎️ uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.ref }} - uses: ./.github/setup diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ad8819f..8f546dce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,8 @@ jobs: steps: - name: Checkout 🛎️ uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} - uses: ./.github/setup diff --git a/nx.json b/nx.json index de91e7b1..a3577435 100644 --- a/nx.json +++ b/nx.json @@ -10,8 +10,9 @@ }, "targetDefaults": { "build": { - "dependsOn": ["prepare", "^build"], - "inputs": ["default", "^default", "baseTypescript"] + "dependsOn": ["^build"], + "inputs": ["default", "^default", "baseTypescript"], + "outputs": ["{projectRoot}/dist"] }, "test": { "dependsOn": ["^test"], diff --git a/packages/eslint-plugin/project.json b/packages/eslint-plugin/project.json index 63bf256d..2467cd74 100644 --- a/packages/eslint-plugin/project.json +++ b/packages/eslint-plugin/project.json @@ -23,6 +23,8 @@ "executor": "@nx/vite:test", "outputs": ["{workspaceRoot}/coverage/packages/eslint-plugin"], "options": { + "coverage": true, + "reporters": ["junit"], "passWithNoTests": true, "reportsDirectory": "../../coverage/packages/eslint-plugin" } diff --git a/packages/eslint-plugin/vite.config.ts b/packages/eslint-plugin/vite.config.ts index feb3912e..036f1152 100644 --- a/packages/eslint-plugin/vite.config.ts +++ b/packages/eslint-plugin/vite.config.ts @@ -13,6 +13,7 @@ export default defineConfig({ test: { globals: true, + outputFile: '../../coverage/packages/eslint-plugin/report.junit.xml', cache: { dir: '../../node_modules/.vitest', },