From 09f352a3813fbdea60f16f75025a95650a3828cd Mon Sep 17 00:00:00 2001 From: Johannes Homeier Date: Fri, 15 Dec 2023 15:48:20 +0100 Subject: [PATCH] ci: use node version file --- .github/workflows/ci.yml | 115 ++++++++++++++--------------- .github/workflows/deploy-demo.yml | 70 +++++++++--------- .github/workflows/publish-docs.yml | 56 +++++++------- 3 files changed, 120 insertions(+), 121 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54fc198..6e32b26 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,81 +13,80 @@ jobs: install-deps: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Cache node modules - id: cache - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - uses: actions/setup-node@v3 - if: steps.cache.outputs.cache-hit != 'true' - with: - node-version: 16.x - - name: NPM install - if: steps.cache.outputs.cache-hit != 'true' - run: npm ci + - name: Checkout + uses: actions/checkout@v4 + - name: Cache node modules + id: cache + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - uses: actions/setup-node@v3 + if: steps.cache.outputs.cache-hit != 'true' + with: + node-version-file: '.nvmrc' + - name: NPM install + if: steps.cache.outputs.cache-hit != 'true' + run: npm ci lint: runs-on: ubuntu-latest needs: install-deps steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: git fetch --no-tags --prune --depth=1 origin develop - - name: Cache node modules - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --no-tags --prune --depth=1 origin develop + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - run: npx nx affected --target=lint --parallel=3 --base=origin/develop + - run: npx nx affected --target=lint --parallel=3 --base=origin/develop test: runs-on: ubuntu-latest needs: install-deps steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: git fetch --no-tags --prune --depth=1 origin develop - - name: Cache node modules - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --no-tags --prune --depth=1 origin develop + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - run: npx nx affected --target=test --parallel=3 --configuration=ci --base=origin/develop --codeCoverage + - run: npx nx affected --target=test --parallel=3 --configuration=ci --base=origin/develop --codeCoverage - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} build: runs-on: ubuntu-latest needs: install-deps steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - run: git fetch --no-tags --prune --depth=1 origin develop - - name: Cache node modules - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --no-tags --prune --depth=1 origin develop + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - run: npx nx affected:build --parallel=3 --base=origin/develop - - - name: Archive production artifacts - uses: actions/upload-artifact@v3 - with: - name: dist - path: dist + - run: npx nx affected:build --parallel=3 --base=origin/develop + - name: Archive production artifacts + uses: actions/upload-artifact@v3 + with: + name: dist + path: dist diff --git a/.github/workflows/deploy-demo.yml b/.github/workflows/deploy-demo.yml index 39849b4..3d6babc 100644 --- a/.github/workflows/deploy-demo.yml +++ b/.github/workflows/deploy-demo.yml @@ -4,7 +4,7 @@ name: Deploy Demo to Github Pages on: # Runs on pushes targeting the default branch push: - branches: [ "main" ] + branches: ['main'] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -18,27 +18,27 @@ permissions: # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: - group: "pages" + group: 'pages' cancel-in-progress: false jobs: install-deps: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Cache node modules - id: cache - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - uses: actions/setup-node@v4 - if: steps.cache.outputs.cache-hit != 'true' - with: - node-version: 20.x - - name: NPM install - if: steps.cache.outputs.cache-hit != 'true' - run: npm ci + - uses: actions/checkout@v4 + - name: Cache node modules + id: cache + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - uses: actions/setup-node@v4 + if: steps.cache.outputs.cache-hit != 'true' + with: + node-version-file: '.nvmrc' + - name: NPM install + if: steps.cache.outputs.cache-hit != 'true' + run: npm ci # Single deploy job since we're just deploying deploy: @@ -48,24 +48,24 @@ jobs: runs-on: ubuntu-latest needs: install-deps steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Cache node modules - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - name: Setup Pages - uses: actions/configure-pages@v3 + - name: Checkout + uses: actions/checkout@v4 + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - name: Setup Pages + uses: actions/configure-pages@v3 - - name: Build Demo - run: npx nx build demo -c github + - name: Build Demo + run: npx nx build demo -c github - - name: Upload artifact - uses: actions/upload-pages-artifact@v2 - with: - # Upload entire repository - path: './dist/apps/demo' - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v2 + - name: Upload artifact + uses: actions/upload-pages-artifact@v2 + with: + # Upload entire repository + path: './dist/apps/demo' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 2b21118..db95f78 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -2,7 +2,7 @@ name: Publish Docs to the Wiki on: push: - branches: [ "main" ] + branches: ['main'] workflow_dispatch: @@ -17,36 +17,36 @@ jobs: install-deps: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Cache node modules - id: cache - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - uses: actions/setup-node@v4 - if: steps.cache.outputs.cache-hit != 'true' - with: - node-version: 20.x - - name: NPM install - if: steps.cache.outputs.cache-hit != 'true' - run: npm ci + - uses: actions/checkout@v4 + - name: Cache node modules + id: cache + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - uses: actions/setup-node@v4 + if: steps.cache.outputs.cache-hit != 'true' + with: + node-version-file: '.nvmrc' + - name: NPM install + if: steps.cache.outputs.cache-hit != 'true' + run: npm ci publish: runs-on: ubuntu-latest needs: install-deps steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Cache node modules - uses: actions/cache@v3 - with: - path: node_modules - key: cache-node-modules-${{ hashFiles('package-lock.json') }} - - name: Build Docs - run: scripts/build-docs.sh + - name: Checkout + uses: actions/checkout@v4 + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: cache-node-modules-${{ hashFiles('package-lock.json') }} + - name: Build Docs + run: scripts/build-docs.sh - - name: Upload Docs to Wiki - uses: Andrew-Chen-Wang/github-wiki-action@v4 - with: - path: 'docs' + - name: Upload Docs to Wiki + uses: Andrew-Chen-Wang/github-wiki-action@v4 + with: + path: 'docs'