From 4d98231a6838fd53a1e877ef7e22cf513a9d9d06 Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Thu, 4 Apr 2024 12:04:49 +0100 Subject: [PATCH 1/8] ci: extract workflows from `build` job to new `lint` and `test` jobs --- .github/workflows/build.yml | 30 +++++++++++++++--------------- .github/workflows/lint.yml | 31 +++++++++++++++++++++++++++++++ .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c334c6aca..549a61dff 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,20 +11,20 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 - - name: Use Node.js latest - uses: actions/setup-node@v3 - with: - node-version: latest + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: latest - - name: Build - run: | - npm ci - npm run commitlint - npm run lint - npm run bundle - npm run bundle-min - npm test + - name: Install dependencies + run: npm ci + + - name: Build + run: | + npm run bundle + npm run bundle-min diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..f44b3f34c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Lint + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: latest + + - name: Install dependencies + run: npm ci + + - name: commitlint + run: npm run commitlint + + - name: lint + run: npm run lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..04d946fe0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +name: Test + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: latest + + - name: Install dependencies + run: npm ci + + - name: Test + run: npm test From b60f6eef7129bba521420719c9b1547686754500 Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Thu, 4 Apr 2024 15:04:45 +0100 Subject: [PATCH 2/8] ci: remove fetch-depth from test and build jobs --- .github/workflows/build.yml | 2 -- .github/workflows/test.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 549a61dff..6426b8b3c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,8 +13,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 04d946fe0..67e2bd636 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,8 +13,6 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - with: - fetch-depth: 0 - name: Setup Node.js uses: actions/setup-node@v3 From 47e4449b75dbc0c5ea46e0cfc60b4717aed83f03 Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Thu, 4 Apr 2024 15:22:44 +0100 Subject: [PATCH 3/8] ci: make test job require a successful build --- .github/workflows/build.yml | 5 +++++ .github/workflows/test.yml | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6426b8b3c..60eec3714 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,3 +26,8 @@ jobs: run: | npm run bundle npm run bundle-min + + test: + needs: build + uses: ./.github/workflows/test.yml + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 67e2bd636..2c51570af 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,10 +1,6 @@ name: Test -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] +on: workflow_call jobs: test: From aba3e041d43964d6a5d9a3be15590327400ffe4f Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Thu, 4 Apr 2024 16:32:28 +0100 Subject: [PATCH 4/8] ci: extract job setup into `setup.yml` For `lint`, `build`, and `test` jobs. --- .github/workflows/build.yml | 12 ++---------- .github/workflows/lint.yml | 14 ++------------ .github/workflows/setup.yml | 19 +++++++++++++++++++ .github/workflows/test.yml | 12 ++---------- 4 files changed, 25 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/setup.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 60eec3714..4fdfb9414 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,16 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - - - name: Install dependencies - run: npm ci + - name: Setup + uses: ./.github/workflows/setup.yml - name: Build run: | diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f44b3f34c..3957b50a4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,18 +11,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - - - name: Install dependencies - run: npm ci + - name: Setup + uses: ./.github/workflows/setup.yml - name: commitlint run: npm run commitlint diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml new file mode 100644 index 000000000..0979c01c7 --- /dev/null +++ b/.github/workflows/setup.yml @@ -0,0 +1,19 @@ +name: Setup + +on: workflow_call + +jobs: + setup: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: latest + + - name: Install dependencies + run: npm ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c51570af..804ae150d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,16 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - - - name: Install dependencies - run: npm ci + - name: Setup + uses: ./.github/workflows/setup.yml - name: Test run: npm test From 10b97c0663eed52073253bc6c812f13f31633c0e Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Thu, 4 Apr 2024 16:49:32 +0100 Subject: [PATCH 5/8] ci: make test job use build job's artifacts --- .github/workflows/build.yml | 21 +++++++++++++++++++-- .github/workflows/test.yml | 3 --- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4fdfb9414..f58e22239 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: Build & Test on: push: @@ -19,7 +19,24 @@ jobs: npm run bundle npm run bundle-min + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-artifacts + path: ./packages/**/build + test: needs: build - uses: ./.github/workflows/test.yml + runs-on: ubuntu-latest + + steps: + - name: Setup + uses: ./.github/workflows/setup.yml + + - name: Download build artifacts + uses: actions/download-artifact@v4 + run: ls -R + + - name: Test + uses: ./.github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 804ae150d..118f612ad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,8 +7,5 @@ jobs: runs-on: ubuntu-latest steps: - - name: Setup - uses: ./.github/workflows/setup.yml - - name: Test run: npm test From 7a12227551b87dcd2155502b8dca244bf28a9530 Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Thu, 4 Apr 2024 16:52:22 +0100 Subject: [PATCH 6/8] ci: fix setup job failure --- .github/workflows/build.yml | 2 ++ .github/workflows/setup.yml | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f58e22239..75058fdc6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,8 @@ jobs: - name: Download build artifacts uses: actions/download-artifact@v4 + + - name: Display structure of downloaded artifacts run: ls -R - name: Test diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml index 0979c01c7..5f1415430 100644 --- a/.github/workflows/setup.yml +++ b/.github/workflows/setup.yml @@ -8,10 +8,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v3 with: node-version: latest From e3dcfbf018db6e51960943437af533af0392b058 Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Tue, 16 Apr 2024 15:49:57 +0100 Subject: [PATCH 7/8] ci: try new development/release workflows --- .github/workflows/build.yml | 44 ------------------------ .github/workflows/development.yml | 57 +++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 21 ------------ .github/workflows/npm-publish.yml | 40 ---------------------- .github/workflows/release.yml | 33 ++++++++++++++++++ .github/workflows/setup.yml | 19 ----------- .github/workflows/test.yml | 11 ------ 7 files changed, 90 insertions(+), 135 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/development.yml delete mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/npm-publish.yml create mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/setup.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 75058fdc6..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Build & Test - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Setup - uses: ./.github/workflows/setup.yml - - - name: Build - run: | - npm run bundle - npm run bundle-min - - - name: Upload build artifacts - uses: actions/upload-artifact@v4 - with: - name: build-artifacts - path: ./packages/**/build - - test: - needs: build - runs-on: ubuntu-latest - - steps: - - name: Setup - uses: ./.github/workflows/setup.yml - - - name: Download build artifacts - uses: actions/download-artifact@v4 - - - name: Display structure of downloaded artifacts - run: ls -R - - - name: Test - uses: ./.github/workflows/test.yml - diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml new file mode 100644 index 000000000..29ee171fa --- /dev/null +++ b/.github/workflows/development.yml @@ -0,0 +1,57 @@ +name: Development + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + workflow_call: + +jobs: + build-test: + name: Build and test + runs-on: ubuntu-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: "Setup Node" + uses: actions/setup-node@v3 + with: + node-version: latest + + - name: "Install dependencies" + run: npm ci + + - name: "Build" + run: | + npm run bundle + npm run bundle-min + + - name: "Run tests" + run: npm test + + lint: + name: Code standards + runs-on: ubuntu-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: "Setup Node" + uses: actions/setup-node@v3 + with: + node-version: latest + + - name: "Install dependencies" + run: npm ci + + - name: "Lint code" + run: npm run lint + + - name: "Lint commit" + run: npm run commitlint \ No newline at end of file diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 3957b50a4..000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Lint - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Setup - uses: ./.github/workflows/setup.yml - - - name: commitlint - run: npm run commitlint - - - name: lint - run: npm run lint diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml deleted file mode 100644 index 4ae893b34..000000000 --- a/.github/workflows/npm-publish.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Node.js Package - -on: - push: - branches: [ "master" ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: latest - - name: Build - run: | - npm ci - npm run commitlint - npm run lint - npm run bundle - npm run bundle-min - npm test - - publish-npm: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - uses: actions/setup-node@v3 - with: - node-version: latest - registry-url: https://registry.npmjs.org/ - - run: npm ci - - run: npm run publish - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..202f3e3df --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: Release + +on: + push: + branches: [ "master" ] + +jobs: + build-test-lint: + name: Build, test, and lint + uses: d3fc/d3fc/.github/workflows/development.yml@main + + publish-npm: + needs: build-test-lint + runs-on: ubuntu-latest + steps: + - name: "Checkout repository" + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: "Setup Node" + uses: actions/setup-node@v3 + with: + node-version: latest + registry-url: https://registry.npmjs.org/ + + - name: "Install dependencies" + run: npm ci + + - name: "Publish" + run: npm run publish + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} \ No newline at end of file diff --git a/.github/workflows/setup.yml b/.github/workflows/setup.yml deleted file mode 100644 index 5f1415430..000000000 --- a/.github/workflows/setup.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Setup - -on: workflow_call - -jobs: - setup: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: latest - - - name: Install dependencies - run: npm ci diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 118f612ad..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Test - -on: workflow_call - -jobs: - test: - runs-on: ubuntu-latest - - steps: - - name: Test - run: npm test From 1ebcd83d2f62a410d99c274d74a7cbafeb09180e Mon Sep 17 00:00:00 2001 From: Cara Fisher Date: Wed, 17 Apr 2024 12:18:22 +0100 Subject: [PATCH 8/8] ci: Add name to `publish-npm` job in `release.yml` --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 202f3e3df..59ef97272 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ jobs: uses: d3fc/d3fc/.github/workflows/development.yml@main publish-npm: + name: Publish npm package(s) needs: build-test-lint runs-on: ubuntu-latest steps: