Skip to content

Commit

Permalink
ci: fix nx branch setup
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SimeonC committed Sep 28, 2023
1 parent 5c3b461 commit e0c94bc
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
10 changes: 8 additions & 2 deletions .github/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@ 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
with:
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 🔧
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 3 additions & 11 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 🛎️
Expand All @@ -40,7 +31,6 @@ jobs:
OSSI_TOKEN: ${{ secrets.OSSI_TOKEN }}

test:
needs: [setup]
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
Expand All @@ -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
Expand All @@ -64,6 +54,8 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}

- uses: ./.github/setup

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
ref: ${{ github.ref }}

- uses: ./.github/setup

Expand Down
5 changes: 3 additions & 2 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
2 changes: 2 additions & 0 deletions packages/eslint-plugin/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
1 change: 1 addition & 0 deletions packages/eslint-plugin/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default defineConfig({

test: {
globals: true,
outputFile: '../../coverage/packages/eslint-plugin/report.junit.xml',
cache: {
dir: '../../node_modules/.vitest',
},
Expand Down

0 comments on commit e0c94bc

Please sign in to comment.