From a7bd5eb8c92332ab7bca6c887477cda0840b7716 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 13 Jun 2024 15:56:25 +0200 Subject: [PATCH 1/5] Upgrade Github actions --- .github/workflows/build-and-test.yml | 26 +++++++++++----------- .github/workflows/dockercompose.yml | 4 ++-- .github/workflows/linter.yml | 4 ++-- .github/workflows/publish-test-results.yml | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index df4431b000..472694de11 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -12,10 +12,10 @@ jobs: python-version: ["3.7", "3.9", "3.10"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: "Cache pip packages" - uses: actions/cache@v3 + uses: actions/cache@v4 id: pip-cache with: path: ~/.cache/pip @@ -24,14 +24,14 @@ jobs: ${{ runner.os }}-pip- - name: "Cache tox environments" - uses: actions/cache@v3 + uses: actions/cache@v4 id: tox-cache with: path: .tox key: ${{ runner.os }}-tox-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt', '**/requirements/*.txt', 'tox.ini') }} - name: "Set up Python ${{ matrix.python-version }}" - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} @@ -84,9 +84,9 @@ jobs: - name: Upload Selenium driver logs (${{ matrix.python-version }}) if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: pytest-logs + name: pytest-logs-${{ matrix.python-version }} path: | /tmp/pytest-of-runner @@ -99,17 +99,17 @@ jobs: - name: Upload test reports (${{ matrix.python-version }}) if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: test-reports + name: test-reports-${{ matrix.python-version }} path: | reports/**/* - name: Upload core dumps (${{ matrix.python-version }}) if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: core-dumps + name: core-dumps-${{ matrix.python-version }} path: | /tmp/core-* @@ -130,11 +130,11 @@ jobs: name: "Test Javascript code" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: browser-actions/setup-chrome@latest - uses: browser-actions/setup-firefox@latest - run: chrome --version - - uses: actions/setup-node@v3 + - uses: actions/setup-node@v4 with: node-version: 16 @@ -149,7 +149,7 @@ jobs: - name: Upload JavaScript test reports if: always() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: javascript-test-reports path: | diff --git a/.github/workflows/dockercompose.yml b/.github/workflows/dockercompose.yml index 893c299c3d..23f36c37ea 100644 --- a/.github/workflows/dockercompose.yml +++ b/.github/workflows/dockercompose.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: docker-compose build run: | @@ -37,7 +37,7 @@ jobs: - name: Send GitHub Action trigger data to Slack workflow id: slack if: failure() - uses: slackapi/slack-github-action@v1.23.0 + uses: slackapi/slack-github-action@v1.26.0 with: payload: | { diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 0a5d16cc48..e351306a02 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -39,7 +39,7 @@ jobs: # Checkout the code base # ########################## - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # Full git history is needed to get a proper list of changed files within `super-linter` fetch-depth: 0 @@ -48,7 +48,7 @@ jobs: # Run Linter against code base # ################################ - name: Lint Code Base - uses: github/super-linter@v4 + uses: github/super-linter/slim@v6 env: VALIDATE_ALL_CODEBASE: false DEFAULT_BRANCH: master diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml index da798e1b9d..2b1571b77f 100644 --- a/.github/workflows/publish-test-results.yml +++ b/.github/workflows/publish-test-results.yml @@ -30,7 +30,7 @@ jobs: done - name: "Publish test results" - uses: EnricoMi/publish-unit-test-result-action/composite@v1 + uses: EnricoMi/publish-unit-test-result-action@v2 with: commit: ${{ github.event.workflow_run.head_sha }} check_name: "Test results" From 3951b696c8a1b6282b777057e66dd1e2662548d1 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 13 Jun 2024 15:57:25 +0200 Subject: [PATCH 2/5] Move codecov upload to publish tests workflow --- .github/workflows/build-and-test.yml | 7 ------- .github/workflows/publish-test-results.yml | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 472694de11..1d93868a0b 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -90,13 +90,6 @@ jobs: path: | /tmp/pytest-of-runner - - name: "Upload coverage to Codecov" - if: github.repository_owner == 'Uninett' - uses: codecov/codecov-action@v4 - with: - fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} # not required for forks of public repos - - name: Upload test reports (${{ matrix.python-version }}) if: always() uses: actions/upload-artifact@v4 diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml index 2b1571b77f..cba73e1773 100644 --- a/.github/workflows/publish-test-results.yml +++ b/.github/workflows/publish-test-results.yml @@ -35,3 +35,10 @@ jobs: commit: ${{ github.event.workflow_run.head_sha }} check_name: "Test results" files: artifacts/**/*-results.xml + + - name: "Upload coverage to Codecov" + if: github.repository_owner == 'Uninett' + uses: codecov/codecov-action@v4 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} # not required for forks of public repos From a050390771375c101f6c561a231e441757ca6332 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 13 Jun 2024 15:59:02 +0200 Subject: [PATCH 3/5] Upload PR number and base SHA as artifact For later use in configuring codecov --- .github/workflows/build-and-test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 1d93868a0b..a3bd8952a4 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -147,3 +147,24 @@ jobs: name: javascript-test-reports path: | reports/**/* + + upload-pr-number-base-sha: + name: Save PR number and base SHA in artifact + runs-on: ubuntu-latest + if: ${{ github.event.number && always() }} + env: + PR_NUMBER: ${{ github.event.number }} + BASE_SHA: ${{ github.event.pull_request.base.sha }} + steps: + - name: Make PR number file + run: | + mkdir -p ./extra + echo $PR_NUMBER > ./extra/pr_number + - name: Make base SHA file + run: | + echo $BASE_SHA > ./extra/base_sha + - name: Upload PR number file and base SHA file + uses: actions/upload-artifact@v4 + with: + name: extra + path: extra/ From 4be8b7330b09e11de745ae2e047380880b37fce4 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 13 Jun 2024 16:00:42 +0200 Subject: [PATCH 4/5] Only publish test results/coverage if Uninett repo When running this workflow in a fork context we do not have the necessary permissions --- .github/workflows/publish-test-results.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml index cba73e1773..b6626fb6e6 100644 --- a/.github/workflows/publish-test-results.yml +++ b/.github/workflows/publish-test-results.yml @@ -10,8 +10,7 @@ jobs: publish-test-results: name: "Publish test results" runs-on: ubuntu-latest - if: > - github.event.workflow_run.conclusion != 'skipped' + if: github.event.workflow_run.conclusion != 'skipped' && github.repository_owner == 'Uninett' steps: - name: Download and Extract Artifacts @@ -37,7 +36,6 @@ jobs: files: artifacts/**/*-results.xml - name: "Upload coverage to Codecov" - if: github.repository_owner == 'Uninett' uses: codecov/codecov-action@v4 with: fail_ci_if_error: true From 0e53189d41ad36c11f070d6745ddf994cda47f25 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Thu, 13 Jun 2024 16:01:41 +0200 Subject: [PATCH 5/5] Use artifacts to configure codecov --- .github/workflows/publish-test-results.yml | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-test-results.yml b/.github/workflows/publish-test-results.yml index b6626fb6e6..1b707951e7 100644 --- a/.github/workflows/publish-test-results.yml +++ b/.github/workflows/publish-test-results.yml @@ -35,8 +35,31 @@ jobs: check_name: "Test results" files: artifacts/**/*-results.xml + - name: Read PR number file + if: ${{ hashFiles('artifacts/extra/pr_number') != '' }} + run: | + pr_number=$(cat artifacts/extra/pr_number) + re='^[0-9]+$' + if [[ $pr_number =~ $re ]] ; then + echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV + fi + + - name: Read base SHA file + if: ${{ hashFiles('artifacts/extra/base_sha') != '' }} + run: | + base_sha=$(cat artifacts/extra/base_sha) + re='[0-9a-f]{40}' + if [[ $base_sha =~ $re ]] ; then + echo "BASE_SHA=$base_sha" >> $GITHUB_ENV + fi + - name: "Upload coverage to Codecov" uses: codecov/codecov-action@v4 with: fail_ci_if_error: true - token: ${{ secrets.CODECOV_TOKEN }} # not required for forks of public repos + token: ${{ secrets.CODECOV_TOKEN }} + verbose: true + override_branch: ${{ github.event.workflow_run.head_branch}} + override_commit: ${{ github.event.workflow_run.head_sha}} + commit_parent: ${{ env.BASE_SHA }} + override_pr: ${{ env.PR_NUMBER }}