From ddda8782c09376c4cf0416f9c96bc32f8798616f Mon Sep 17 00:00:00 2001 From: Mathis Hofer Date: Tue, 30 Apr 2024 09:26:36 +0200 Subject: [PATCH] Read Node.js version from .nvmrc in GitHub Actions workflows --- .github/workflows/bom.yml | 11 ++++++----- .github/workflows/build.yml | 13 +++++++------ .github/workflows/lintAndTest.yml | 29 ----------------------------- .github/workflows/test.yml | 31 +++++++++++++++++++++++++++++++ README.md | 4 ++-- 5 files changed, 46 insertions(+), 42 deletions(-) delete mode 100644 .github/workflows/lintAndTest.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/bom.yml b/.github/workflows/bom.yml index bbbe05cab..93e52df78 100644 --- a/.github/workflows/bom.yml +++ b/.github/workflows/bom.yml @@ -6,9 +6,6 @@ on: workflow_dispatch: -env: - NODE_VERSION: 20 - jobs: bom: runs-on: ubuntu-latest @@ -17,10 +14,14 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v4 - - name: Use Node.js ${{ env.NODE_VERSION }} + - name: Read .nvmrc + run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc) + id: nvm + + - name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }} uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version: ${{ steps.nvm.outputs.NODE_VERSION }} cache: "npm" - name: Install @cyclonedx/cyclonedx-npm diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0ce7e57a..211c6db4c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,12 +1,9 @@ -name: build 🏭 integrate ⛙ zip 🗜️ +name: Build, Integrate & ZIP on: push: branches: [main] -env: - NODE_VERSION: 20 - jobs: build: runs-on: ubuntu-latest @@ -21,10 +18,14 @@ jobs: scripts key: build-${{ github.sha }} - - name: Use Node.js ${{ env.NODE_VERSION }} + - name: Read .nvmrc + run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT + id: nvm + + - name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }} uses: actions/setup-node@v4 with: - node-version: ${{ env.NODE_VERSION }} + node-version: ${{ steps.nvm.outputs.NODE_VERSION }} cache: npm - name: Build 🏭 diff --git a/.github/workflows/lintAndTest.yml b/.github/workflows/lintAndTest.yml deleted file mode 100644 index f474ad0d8..000000000 --- a/.github/workflows/lintAndTest.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: lint test ✨ - -on: - push: - pull_request: - -env: - NODE_VERSION: 20 - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Use Node.js ${{ env.NODE_VERSION }} - uses: actions/setup-node@v4 - with: - node-version: ${{ env.NODE_VERSION }} - cache: npm - - - name: lint - run: | - npm install - npm run lint - - - name: test - run: npm run test:headless diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..4ab07ec36 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,31 @@ +name: Lint & Test + +on: + push: + pull_request: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Read .nvmrc + run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT + id: nvm + + - name: Use Node.js ${{ steps.nvm.outputs.NODE_VERSION }} + uses: actions/setup-node@v4 + with: + node-version: ${{ steps.nvm.outputs.NODE_VERSION }} + cache: npm + + - name: Lint + run: | + npm install + npm run lint + + - name: Test + run: npm run test:headless diff --git a/README.md b/README.md index c33c3c55d..3be33c92d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # webapp-schulverwaltung -[![lint/test ✨](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/lintAndTest.yml/badge.svg?branch=main)](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/lintAndTest.yml) -[![build/zip 🚀](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/build.yml/badge.svg)](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/build.yml) +[![Lint & Test](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/test.yml) +[![Build, Integrate & ZIP](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/build.yml/badge.svg)](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/build.yml) [![SBOM](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/bom.yml/badge.svg?branch=main)](https://github.com/bkd-mba-fbi/webapp-schulverwaltung/actions/workflows/bom.yml) JavaScript web module to implement processes for school administration using the SLH.Evento backend (REST API).