From b4c78d49ebf3f7af2b2a4d228bd4454aa4c35812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 20:11:32 +0100 Subject: [PATCH 01/21] Create CI workflow for Node.JS --- .github/workflows/node-ci.yml | 104 +++++++++++++++++++++++++++ actions/node-ci/action.yml | 128 ++++++++++++++++++++++++++++++++++ 2 files changed, 232 insertions(+) create mode 100644 .github/workflows/node-ci.yml create mode 100644 actions/node-ci/action.yml diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml new file mode 100644 index 0000000..cc7be71 --- /dev/null +++ b/.github/workflows/node-ci.yml @@ -0,0 +1,104 @@ +name: Node CI + +on: + workflow_call: + # Inputs the workflow accepts. + + inputs: + node-version: + type: string + description: "Node version" + required: true + + package-manager: + type: string + description: "The package manager to use (npm or yarn)" + required: true + + cache-lockfile-path: + type: string + description: "Path to the lockfile that will be used as cache key" + default: "" + + working-directory-scripts: + type: string + description: "Working directory when running npm scripts" + default: "." + + working-directory-install: + type: string + description: "Working directory when installing dependencies. default = working-directory-scripts" + default: "" + + lint-script: + type: string + description: "Lint npm script name" + default: "lint" + + pre-build-command: + type: string + description: "Pre build command" + default: "exit 0" + + build-script: + type: string + description: "Build npm script name" + default: "build" + + post-install-command: + type: string + description: "Post install command" + default: "exit 0" + + test-script: + type: string + description: "Test npm script name" + default: "test" + + skip-install: + type: boolean + description: "Skip install" + default: false + skip-lint: + type: boolean + description: "Skip lint" + default: false + skip-build: + type: boolean + description: "Skip build" + default: false + skip-test: + type: boolean + description: "Skip test" + default: false + + build-artifacts: + type: string + description: "Build artifacts location (leave empty to disable uploading)" + default: "" + +jobs: + node-ci: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Node CI + uses: ./actions/node-ci + with: + node-version: ${{ inputs.node-version }} + package-manager: ${{ inputs.package-manager }} + cache-lockfile-path: ${{ inputs.cache-lockfile-path }} + working-directory-scripts: ${{ inputs.working-directory-scripts }} + working-directory-install: ${{ inputs.working-directory-install }} + lint-script: ${{ inputs.lint-script }} + pre-build-command: ${{ inputs.pre-build-command }} + build-script: ${{ inputs.build-script }} + post-install-command: ${{ inputs.post-install-command }} + test-script: ${{ inputs.test-script }} + skip-install: ${{ inputs.skip-install }} + skip-lint: ${{ inputs.skip-lint }} + skip-build: ${{ inputs.skip-build }} + skip-test: ${{ inputs.skip-test }} + build-artifacts: ${{ inputs.build-artifacts }} diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml new file mode 100644 index 0000000..a75588d --- /dev/null +++ b/actions/node-ci/action.yml @@ -0,0 +1,128 @@ +name: "Node CI" +description: "Run install, lint, build and test" + +inputs: + node-version: + description: "Node version" + required: true + + package-manager: + description: "The package manager to use (npm or yarn)" + required: true + + cache-lockfile-path: + description: "Path to the lockfile that will be used as cache key" + default: "" + + working-directory-scripts: + description: "Working directory when running npm scripts" + default: "." + + working-directory-install: + description: "Working directory when installing dependencies. default = working-directory-scripts" + default: "" + + lint-script: + description: "Lint npm script name" + default: "lint" + pre-build-command: + description: "Pre build command" + default: "exit 0" + build-script: + description: "Build npm script name" + default: "build" + post-install-command: + description: "Post install command" + default: "exit 0" + test-script: + description: "Test npm script name" + default: "test" + + skip-install: + description: "Skip install" + default: "false" + skip-lint: + description: "Skip lint" + default: "false" + skip-build: + description: "Skip build" + default: "false" + skip-test: + description: "Skip test" + default: "false" + + build-artifacts: + description: "Build artifacts (leave empty to disable uploading)" + default: "" + +runs: + using: "composite" + steps: + - name: On unsupported package manager + if: ${{ inputs.package-manager != 'npm' && inputs.package-manager != 'yarn' }} + shell: bash + run: |- + echo "Unsupported package manager: ${{ inputs.package-manager }}" + exit 1 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: ${{ inputs.package-manager }} + cache-dependency-path: ${{ inputs.cache-lockfile-path }} + + - name: Install dependencies (with npm) + shell: bash + if: ${{ inputs.skip-install == 'false' && inputs.package-manager == 'npm' }} + run: npm ci + working-directory: ${{ inputs.working-directory-install || inputs.working-directory-scripts }} + + - name: Install dependencies (with yarn) + shell: bash + if: ${{ inputs.skip-install == 'false' && inputs.package-manager == 'yarn' }} + run: yarn install --frozen-lockfile + working-directory: ${{ inputs.working-directory-install || inputs.working-directory-scripts }} + + - name: Lint + if: ${{ inputs.skip-lint == 'false' }} + shell: bash + run: |- + set -euo pipefail + ${{ inputs.package-manager }} run ${{ inputs.lint-script }} + working-directory: ${{ inputs.working-directory-scripts }} + + - name: Build + if: ${{ inputs.skip-build == 'false' }} + shell: bash + run: |- + set -euo pipefail + ${{ inputs.package-manager }} run ${{ inputs.build-script }} + working-directory: ${{ inputs.working-directory-scripts }} + + - name: Test + if: ${{ inputs.skip-test == 'false' }} + shell: bash + run: |- + set -euo pipefail + ${{ inputs.package-manager }} run ${{ inputs.test-script }} + working-directory: ${{ inputs.working-directory-scripts }} + + - name: Upload coverage + if: ${{ inputs.skip-test == 'false' }} + uses: actions/upload-artifact@v2 + with: + name: coverage + path: coverage + retention-days: 1 + if-no-files-found: error + working-directory: ${{ inputs.working-directory-scripts }} + + - name: Upload build + if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts != '' }} + uses: actions/upload-artifact@v4 + with: + name: build + path: ${{ inputs.build-artifacts }} + retention-days: 7 + if-no-files-found: error From 86e7dfe4258d6ce3cb1231a87614a6254380253e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 20:21:51 +0100 Subject: [PATCH 02/21] Attempt to fix cwd --- actions/node-ci/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index a75588d..9782866 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -16,7 +16,7 @@ inputs: working-directory-scripts: description: "Working directory when running npm scripts" - default: "." + default: "./" working-directory-install: description: "Working directory when installing dependencies. default = working-directory-scripts" From 5ab2b0143a55ca08f84c6e20988a7baa67d645ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 20:24:09 +0100 Subject: [PATCH 03/21] attempt 2 --- actions/node-ci/action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index 9782866..fc2c81a 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -116,7 +116,6 @@ runs: path: coverage retention-days: 1 if-no-files-found: error - working-directory: ${{ inputs.working-directory-scripts }} - name: Upload build if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts != '' }} From 3fd9b159f21bdc77ad0cb6d4632925683a4cc6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 20:25:16 +0100 Subject: [PATCH 04/21] Fix incorrect action version --- actions/node-ci/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index fc2c81a..630fec7 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -110,7 +110,7 @@ runs: - name: Upload coverage if: ${{ inputs.skip-test == 'false' }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: coverage path: coverage From 387069c1136ddbaabc65599e61e1a9a7fcd0d04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 20:30:06 +0100 Subject: [PATCH 05/21] Require path for coverage --- actions/node-ci/action.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index 630fec7..63ea5f3 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -51,8 +51,12 @@ inputs: description: "Skip test" default: "false" - build-artifacts: - description: "Build artifacts (leave empty to disable uploading)" + test-coverage-path: + description: "Test coverage files path (leave empty to disable uploading)" + default: "" + + build-artifacts-path: + description: "Build artifacts path (leave empty to disable uploading)" default: "" runs: @@ -109,19 +113,19 @@ runs: working-directory: ${{ inputs.working-directory-scripts }} - name: Upload coverage - if: ${{ inputs.skip-test == 'false' }} + if: ${{ inputs.skip-test == 'false' && inputs.test-coverage-path != ''}} uses: actions/upload-artifact@v4 with: name: coverage - path: coverage - retention-days: 1 + path: ${{ inputs.test-coverage-path}} + retention-days: 7 if-no-files-found: error - name: Upload build - if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts != '' }} + if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts-path != '' }} uses: actions/upload-artifact@v4 with: name: build - path: ${{ inputs.build-artifacts }} + path: ${{ inputs.build-artifacts-path }} retention-days: 7 if-no-files-found: error From 00e1402d82680c1fdef420991959131ef3be8a27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 20:44:52 +0100 Subject: [PATCH 06/21] show test output as action summary --- actions/node-ci/action.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index 63ea5f3..e791d86 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -109,9 +109,14 @@ runs: shell: bash run: |- set -euo pipefail - ${{ inputs.package-manager }} run ${{ inputs.test-script }} + ${{ inputs.package-manager }} run ${{ inputs.test-script }} > ${{ runner.temp }}/test-output.txt working-directory: ${{ inputs.working-directory-scripts }} + - name: Test results + shell: bash + run: cat ${{ runner.temp }}/test-output.txt >> $GITHUB_STEP_SUMMARY + continue-on-error: true + - name: Upload coverage if: ${{ inputs.skip-test == 'false' && inputs.test-coverage-path != ''}} uses: actions/upload-artifact@v4 From 8a1de69735889ede7a608b1e42e4dc2407ec1752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:02:14 +0100 Subject: [PATCH 07/21] Comment test to PR --- actions/node-ci/action.yml | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index e791d86..8015b87 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -105,20 +105,40 @@ runs: working-directory: ${{ inputs.working-directory-scripts }} - name: Test + id: test if: ${{ inputs.skip-test == 'false' }} + env: + LOG_FILE: ${{ runner.temp }}/test-output.txt shell: bash run: |- set -euo pipefail - ${{ inputs.package-manager }} run ${{ inputs.test-script }} > ${{ runner.temp }}/test-output.txt + ${{ inputs.package-manager }} run ${{ inputs.test-script }} > $LOG_FILE + echo "log-file=$LOG_FILE" >> $GITHUB_OUTPUT working-directory: ${{ inputs.working-directory-scripts }} - - name: Test results + - name: Test results to action + if: ${{ steps.test.outputs.log-file != '' }} && always() shell: bash - run: cat ${{ runner.temp }}/test-output.txt >> $GITHUB_STEP_SUMMARY + run: cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY continue-on-error: true + + - name: Test result to PR + if: ${{ steps.test.outputs.log-file != '' }} && github.event_name == 'pull_request' && always() + env: + URL: ${{ github.event.issue.comments_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + continue-on-error: true + run: | + curl \ + -x POST \ + "$URL" \ + -H "Content-Type: application/json" \ + -H "Authorization: token $GITHUB_TOKEN" \ + --data '{ "body": "```\n$(cat ${{ steps.test.outputs.log-file }})\n```" }' - name: Upload coverage - if: ${{ inputs.skip-test == 'false' && inputs.test-coverage-path != ''}} + if: ${{ inputs.skip-test }} == 'false' && ${{ inputs.test-coverage-path }} != ''}} && always() uses: actions/upload-artifact@v4 with: name: coverage @@ -127,7 +147,7 @@ runs: if-no-files-found: error - name: Upload build - if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts-path != '' }} + if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts-path != '' }} && always() uses: actions/upload-artifact@v4 with: name: build From 8ca9eb665ab5e16b5fedcc38058fd897b0216b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:05:42 +0100 Subject: [PATCH 08/21] Add missing permissions --- .github/workflows/node-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index cc7be71..438bc4c 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -80,6 +80,11 @@ on: jobs: node-ci: runs-on: ubuntu-latest + + permissions: + contents: read + issues: write + steps: - name: Checkout repository uses: actions/checkout@v4 From 29261250e26531e53d7b68a0414d5bd4946351a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:11:16 +0100 Subject: [PATCH 09/21] Attempt to fix PR comment action --- actions/node-ci/action.yml | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index 8015b87..bc627b8 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -50,6 +50,10 @@ inputs: skip-test: description: "Skip test" default: "false" + + gh-comment-token: + description: "GitHub token for posting comments" + default: "" test-coverage-path: description: "Test coverage files path (leave empty to disable uploading)" @@ -63,7 +67,7 @@ runs: using: "composite" steps: - name: On unsupported package manager - if: ${{ inputs.package-manager != 'npm' && inputs.package-manager != 'yarn' }} + if: inputs.package-manager != 'npm' && inputs.package-manager != 'yarn' shell: bash run: |- echo "Unsupported package manager: ${{ inputs.package-manager }}" @@ -78,18 +82,18 @@ runs: - name: Install dependencies (with npm) shell: bash - if: ${{ inputs.skip-install == 'false' && inputs.package-manager == 'npm' }} + if: inputs.skip-install == 'false' && inputs.package-manager == 'npm' run: npm ci working-directory: ${{ inputs.working-directory-install || inputs.working-directory-scripts }} - name: Install dependencies (with yarn) shell: bash - if: ${{ inputs.skip-install == 'false' && inputs.package-manager == 'yarn' }} + if: inputs.skip-install == 'false' && inputs.package-manager == 'yarn' run: yarn install --frozen-lockfile working-directory: ${{ inputs.working-directory-install || inputs.working-directory-scripts }} - name: Lint - if: ${{ inputs.skip-lint == 'false' }} + if: inputs.skip-lint == 'false' shell: bash run: |- set -euo pipefail @@ -97,7 +101,7 @@ runs: working-directory: ${{ inputs.working-directory-scripts }} - name: Build - if: ${{ inputs.skip-build == 'false' }} + if: inputs.skip-build == 'false' shell: bash run: |- set -euo pipefail @@ -106,7 +110,7 @@ runs: - name: Test id: test - if: ${{ inputs.skip-test == 'false' }} + if: inputs.skip-test == 'false' env: LOG_FILE: ${{ runner.temp }}/test-output.txt shell: bash @@ -117,16 +121,16 @@ runs: working-directory: ${{ inputs.working-directory-scripts }} - name: Test results to action - if: ${{ steps.test.outputs.log-file != '' }} && always() + if: steps.test.outputs.log-file != '' && always() shell: bash run: cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY continue-on-error: true - name: Test result to PR - if: ${{ steps.test.outputs.log-file != '' }} && github.event_name == 'pull_request' && always() + if: steps.test.outputs.log-file != '' && github.event_name == 'pull_request' && inputs.gh-comment-token != '' && always() env: URL: ${{ github.event.issue.comments_url }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ inputs.gh-comment-token }} shell: bash continue-on-error: true run: | @@ -138,7 +142,7 @@ runs: --data '{ "body": "```\n$(cat ${{ steps.test.outputs.log-file }})\n```" }' - name: Upload coverage - if: ${{ inputs.skip-test }} == 'false' && ${{ inputs.test-coverage-path }} != ''}} && always() + if: inputs.skip-test == 'false' && inputs.test-coverage-path != '' && always() uses: actions/upload-artifact@v4 with: name: coverage @@ -147,7 +151,7 @@ runs: if-no-files-found: error - name: Upload build - if: ${{ inputs.skip-build == 'false' && inputs.build-artifacts-path != '' }} && always() + if: inputs.skip-build == 'false' && inputs.build-artifacts-path != '' && always() uses: actions/upload-artifact@v4 with: name: build From f4dd64a4f5ec3636112fcea543e19139e7320ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:15:49 +0100 Subject: [PATCH 10/21] fix string escapes --- actions/node-ci/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index bc627b8..9a98b1f 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -139,7 +139,7 @@ runs: "$URL" \ -H "Content-Type: application/json" \ -H "Authorization: token $GITHUB_TOKEN" \ - --data '{ "body": "```\n$(cat ${{ steps.test.outputs.log-file }})\n```" }' + --data "{ \"body\": \"```\n$(cat ${{ steps.test.outputs.log-file }})\n```\" }" - name: Upload coverage if: inputs.skip-test == 'false' && inputs.test-coverage-path != '' && always() From d80029759368a8324bc0042319bf264e87e31f0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:20:03 +0100 Subject: [PATCH 11/21] Use an external action instead for comments --- actions/node-ci/action.yml | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index 9a98b1f..0635e5c 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -120,26 +120,21 @@ runs: echo "log-file=$LOG_FILE" >> $GITHUB_OUTPUT working-directory: ${{ inputs.working-directory-scripts }} - - name: Test results to action + - name: Comment Test results to action if: steps.test.outputs.log-file != '' && always() shell: bash run: cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY continue-on-error: true - - name: Test result to PR + - name: Comment Test result to PR if: steps.test.outputs.log-file != '' && github.event_name == 'pull_request' && inputs.gh-comment-token != '' && always() - env: - URL: ${{ github.event.issue.comments_url }} - GITHUB_TOKEN: ${{ inputs.gh-comment-token }} - shell: bash - continue-on-error: true - run: | - curl \ - -x POST \ - "$URL" \ - -H "Content-Type: application/json" \ - -H "Authorization: token $GITHUB_TOKEN" \ - --data "{ \"body\": \"```\n$(cat ${{ steps.test.outputs.log-file }})\n```\" }" + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + Test results: + ${{ steps.test.outputs.log-file }} + token: ${{ inputs.gh-comment-token }} - name: Upload coverage if: inputs.skip-test == 'false' && inputs.test-coverage-path != '' && always() From 23e79ff26bc4610be81b0648968dd25dfa02fb21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:32:23 +0100 Subject: [PATCH 12/21] asddas --- actions/node-ci/action.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index 0635e5c..cdc4d58 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -121,19 +121,22 @@ runs: working-directory: ${{ inputs.working-directory-scripts }} - name: Comment Test results to action + id: test-action-summary if: steps.test.outputs.log-file != '' && always() shell: bash - run: cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY + run: | + cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY + echo result-content=<> $GITHUB_OUTPUT continue-on-error: true - name: Comment Test result to PR - if: steps.test.outputs.log-file != '' && github.event_name == 'pull_request' && inputs.gh-comment-token != '' && always() + if: steps.test-action-summary.outputs.result-content != '' && github.event_name == 'pull_request' && inputs.gh-comment-token != '' && always() uses: peter-evans/create-or-update-comment@v4 with: issue-number: ${{ github.event.pull_request.number }} body: | Test results: - ${{ steps.test.outputs.log-file }} + ${{ steps.test-action-summary.outputs.result-content }} token: ${{ inputs.gh-comment-token }} - name: Upload coverage From 2dea999e8e0a59334ed7af5823066703817178e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:35:46 +0100 Subject: [PATCH 13/21] remove comment to PR action --- .github/workflows/node-ci.yml | 4 ---- actions/node-ci/action.yml | 15 +-------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 438bc4c..f6b48e8 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -81,10 +81,6 @@ jobs: node-ci: runs-on: ubuntu-latest - permissions: - contents: read - issues: write - steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index cdc4d58..b9a4ae6 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -121,23 +121,10 @@ runs: working-directory: ${{ inputs.working-directory-scripts }} - name: Comment Test results to action - id: test-action-summary if: steps.test.outputs.log-file != '' && always() shell: bash - run: | - cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY - echo result-content=<> $GITHUB_OUTPUT + run: cat ${{ steps.test.outputs.log-file }} >> $GITHUB_STEP_SUMMARY continue-on-error: true - - - name: Comment Test result to PR - if: steps.test-action-summary.outputs.result-content != '' && github.event_name == 'pull_request' && inputs.gh-comment-token != '' && always() - uses: peter-evans/create-or-update-comment@v4 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - Test results: - ${{ steps.test-action-summary.outputs.result-content }} - token: ${{ inputs.gh-comment-token }} - name: Upload coverage if: inputs.skip-test == 'false' && inputs.test-coverage-path != '' && always() From 35cfa0cd31bfe089e5c314050c1a4186c7d96d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:36:26 +0100 Subject: [PATCH 14/21] remove unused input --- actions/node-ci/action.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/actions/node-ci/action.yml b/actions/node-ci/action.yml index b9a4ae6..7ddcaf6 100644 --- a/actions/node-ci/action.yml +++ b/actions/node-ci/action.yml @@ -51,10 +51,6 @@ inputs: description: "Skip test" default: "false" - gh-comment-token: - description: "GitHub token for posting comments" - default: "" - test-coverage-path: description: "Test coverage files path (leave empty to disable uploading)" default: "" From 95272a616add570d6d6c76c1e4d5708c4ab5dda5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:39:49 +0100 Subject: [PATCH 15/21] Update workflow inputs --- .github/workflows/node-ci.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index f6b48e8..3ba4f62 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -72,9 +72,14 @@ on: description: "Skip test" default: false - build-artifacts: + test-coverage-path: type: string - description: "Build artifacts location (leave empty to disable uploading)" + description: "Test coverage files path (leave empty to disable uploading)" + default: "" + + build-artifacts-path: + type: string + description: "Build artifacts path (leave empty to disable uploading)" default: "" jobs: @@ -102,4 +107,5 @@ jobs: skip-lint: ${{ inputs.skip-lint }} skip-build: ${{ inputs.skip-build }} skip-test: ${{ inputs.skip-test }} - build-artifacts: ${{ inputs.build-artifacts }} + test-coverage-path: ${{ inputs.test-coverage-path }} + build-artifacts-path: ${{ inputs.build-artifacts-path }} From 018d8cbc7ca0530ef716ca438662e308b1837f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 21:53:05 +0100 Subject: [PATCH 16/21] test workflow import --- .github/workflows/node-ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 3ba4f62..6159dbc 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -89,9 +89,17 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + + - name: Checkout automations repository + uses: actions/checkout@v4 + with: + repository: kir-dev/automations + path: automations + + - run: ls -la && tree - name: Node CI - uses: ./actions/node-ci + uses: ./automations/actions/node-ci with: node-version: ${{ inputs.node-version }} package-manager: ${{ inputs.package-manager }} From e4728961d6db73b76d6c0ccb757b46a6a15940dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 22:01:19 +0100 Subject: [PATCH 17/21] fix path of action --- .github/workflows/node-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 6159dbc..0a0ba5e 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -99,7 +99,7 @@ jobs: - run: ls -la && tree - name: Node CI - uses: ./automations/actions/node-ci + uses: kir-dev/automations/actions/node-ci@node-ci with: node-version: ${{ inputs.node-version }} package-manager: ${{ inputs.package-manager }} From 58be91d2b6ce23ee7af99623a3068dc326a8e336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 22:09:51 +0100 Subject: [PATCH 18/21] Move lint, build, test to different workflows --- .github/workflows/node-ci.yml | 67 ++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 0a0ba5e..6cbeefe 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -55,10 +55,6 @@ on: description: "Test npm script name" default: "test" - skip-install: - type: boolean - description: "Skip install" - default: false skip-lint: type: boolean description: "Skip lint" @@ -70,7 +66,7 @@ on: skip-test: type: boolean description: "Skip test" - default: false + default: true test-coverage-path: type: string @@ -83,37 +79,66 @@ on: default: "" jobs: - node-ci: + lint: runs-on: ubuntu-latest + if: ! inputs.skip-lint steps: - name: Checkout repository uses: actions/checkout@v4 - - - name: Checkout automations repository + + - uses: kir-dev/automations/actions/node-ci@node-ci + with: + node-version: ${{ inputs.node-version }} + package-manager: ${{ inputs.package-manager }} + cache-lockfile-path: ${{ inputs.cache-lockfile-path }} + working-directory-scripts: ${{ inputs.working-directory-scripts }} + working-directory-install: ${{ inputs.working-directory-install }} + lint-script: ${{ inputs.lint-script }} + post-install-command: ${{ inputs.post-install-command }} + skip-build: true + skip-test: true + skip-lint: false + test: + runs-on: ubuntu-latest + if: ! inputs.skip-test + + steps: + - name: Checkout repository uses: actions/checkout@v4 + + - uses: kir-dev/automations/actions/node-ci@node-ci with: - repository: kir-dev/automations - path: automations - - - run: ls -la && tree + node-version: ${{ inputs.node-version }} + package-manager: ${{ inputs.package-manager }} + cache-lockfile-path: ${{ inputs.cache-lockfile-path }} + working-directory-scripts: ${{ inputs.working-directory-scripts }} + working-directory-install: ${{ inputs.working-directory-install }} + post-install-command: ${{ inputs.post-install-command }} + test-script: ${{ inputs.test-script }} + skip-lint: true + skip-build: true + skip-test: false + test-coverage-path: ${{ inputs.test-coverage-path }} + build: + if: ! inputs.skip-build + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 - - name: Node CI - uses: kir-dev/automations/actions/node-ci@node-ci + - uses: kir-dev/automations/actions/node-ci@node-ci with: node-version: ${{ inputs.node-version }} package-manager: ${{ inputs.package-manager }} cache-lockfile-path: ${{ inputs.cache-lockfile-path }} working-directory-scripts: ${{ inputs.working-directory-scripts }} working-directory-install: ${{ inputs.working-directory-install }} - lint-script: ${{ inputs.lint-script }} pre-build-command: ${{ inputs.pre-build-command }} build-script: ${{ inputs.build-script }} post-install-command: ${{ inputs.post-install-command }} - test-script: ${{ inputs.test-script }} - skip-install: ${{ inputs.skip-install }} - skip-lint: ${{ inputs.skip-lint }} - skip-build: ${{ inputs.skip-build }} - skip-test: ${{ inputs.skip-test }} - test-coverage-path: ${{ inputs.test-coverage-path }} + skip-lint: true + skip-test: true + skip-build: false build-artifacts-path: ${{ inputs.build-artifacts-path }} From 43ca056b48330d368dd1d42537b0196cc7ea2a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 22:12:14 +0100 Subject: [PATCH 19/21] fix bools --- .github/workflows/node-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 6cbeefe..eddafbf 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -81,7 +81,7 @@ on: jobs: lint: runs-on: ubuntu-latest - if: ! inputs.skip-lint + if: inputs.skip-lint == 'true' steps: - name: Checkout repository @@ -101,7 +101,7 @@ jobs: skip-lint: false test: runs-on: ubuntu-latest - if: ! inputs.skip-test + if: inputs.skip-test == 'true' steps: - name: Checkout repository @@ -121,7 +121,7 @@ jobs: skip-test: false test-coverage-path: ${{ inputs.test-coverage-path }} build: - if: ! inputs.skip-build + if: inputs.skip-build == 'true' runs-on: ubuntu-latest steps: From 0dfad36326a73cfcc01583a2211ea7ab2f9ab947 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 22:13:06 +0100 Subject: [PATCH 20/21] fix bool condition --- .github/workflows/node-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index eddafbf..bbd55e2 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -81,7 +81,7 @@ on: jobs: lint: runs-on: ubuntu-latest - if: inputs.skip-lint == 'true' + if: inputs.skip-lint != 'true' steps: - name: Checkout repository @@ -101,7 +101,7 @@ jobs: skip-lint: false test: runs-on: ubuntu-latest - if: inputs.skip-test == 'true' + if: inputs.skip-test != 'true' steps: - name: Checkout repository @@ -121,7 +121,7 @@ jobs: skip-test: false test-coverage-path: ${{ inputs.test-coverage-path }} build: - if: inputs.skip-build == 'true' + if: inputs.skip-build != 'true' runs-on: ubuntu-latest steps: From 1b971591fec71137c16e3b973794e6ff4dc11d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20S=C3=BCdi?= Date: Mon, 28 Oct 2024 22:14:39 +0100 Subject: [PATCH 21/21] maybe now --- .github/workflows/node-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index bbd55e2..b7984cf 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -81,7 +81,7 @@ on: jobs: lint: runs-on: ubuntu-latest - if: inputs.skip-lint != 'true' + if: inputs.skip-lint != true steps: - name: Checkout repository @@ -101,7 +101,7 @@ jobs: skip-lint: false test: runs-on: ubuntu-latest - if: inputs.skip-test != 'true' + if: inputs.skip-test != true steps: - name: Checkout repository @@ -121,7 +121,7 @@ jobs: skip-test: false test-coverage-path: ${{ inputs.test-coverage-path }} build: - if: inputs.skip-build != 'true' + if: inputs.skip-build != true runs-on: ubuntu-latest steps: