From c3687e938f1803f8e71d4031306a45005f8ab920 Mon Sep 17 00:00:00 2001 From: Gauthier Fiorentino Date: Thu, 14 Mar 2024 17:34:45 +0100 Subject: [PATCH] CI: Test reusable actions --- .github/actions/build.yml | 23 +++++++++++++++++++++++ .github/actions/tests.yml | 17 +++++++++++++++++ .github/workflows/CI.yml | 7 +++++++ .github/workflows/build.yml | 26 -------------------------- .github/workflows/tests.yml | 20 -------------------- 5 files changed, 47 insertions(+), 46 deletions(-) create mode 100644 .github/actions/build.yml create mode 100644 .github/actions/tests.yml create mode 100644 .github/workflows/CI.yml delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/actions/build.yml b/.github/actions/build.yml new file mode 100644 index 0000000..067549b --- /dev/null +++ b/.github/actions/build.yml @@ -0,0 +1,23 @@ +name: 'Build' + +runs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: +# TODO: add version to a .nvmrc or at least a variable + node-version: 18.12.1 + cache: npm + - name: Install + run: npm ci + - name: Build + run: npm run build + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: lib-${{ github.sha }} + path: ./dist + if-no-files-found: error diff --git a/.github/actions/tests.yml b/.github/actions/tests.yml new file mode 100644 index 0000000..32bbc4a --- /dev/null +++ b/.github/actions/tests.yml @@ -0,0 +1,17 @@ +name: 'Run tests' + +runs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: +# TODO: add version to a .nvmrc or at least a variable + node-version: 18.12.1 + cache: npm + - name: Install + run: npm ci --prefer-offline + - name: Run tests + run: npm run test:unit diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..a2a421f --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,7 @@ +on: [push, workflow_dispatch] + +jobs: + run-tests: + uses: ./.github/actions/tests.yml + build: + uses: ./.github/actions/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 4d04c4e..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: 'Run tests' - -on: [push, workflow_dispatch] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup node - uses: actions/setup-node@v4 - with: - # TODO: add version to a .nvmrc or at least a variable - node-version: 18.12.1 - cache: npm - - name: Install - run: npm ci - - name: Build - run: npm run build - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: lib-${{ github.sha }} - path: ./dist - if-no-files-found: error diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index c4b8e05..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: 'Run tests' - -on: [push, workflow_dispatch] - -jobs: - run-tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup node - uses: actions/setup-node@v4 - with: -# TODO: add version to a .nvmrc or at least a variable - node-version: 18.12.1 - cache: npm - - name: Install - run: npm ci --prefer-offline - - name: Run tests - run: npm run test:unit