From 5e4f52afa391fb8e0e4e8a39417c5598c1f586cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Ro=C5=A1ko?= <156314064+broskoTT@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:44:42 +0100 Subject: [PATCH] Refactor our CI yamls (#319) ### Issue No current issue, related to already closed #45 ### Description As we're using CI for some time, I found that it actually brings unnecessary complications to have a layer of yamls just designating what is done on pr, optionally on pr, and on push. This can be directly added to each of the jobs. Another effect is that in the "Actions" tab, we won't have On PR, Optional On PR, and On Push where each includes several different jobs. We will now have Build device, build and run tests, and pre-commit , which will run both on PR branches and main. ### List of the changes - Created a build-and-run-all-tests.yml which wraps build-tests and run-tests for all archs. This just nicely corresponds exactly to previous on-pr-opt. - Deleted on-pr, on-pr-opt and on-push ymls - Added to all referenced .ymls the config to run on pr and/or on push, so that same jobs are called on same triggers. - Added timeout parameter to a couple of jobs. - I will change in settings which jobs are mandatory, if they are now named slightly different. ### Testing CI passes on this PR ### API Changes There are no API changes in this PR. --- ...pr-opt.yml => build-and-run-all-tests.yml} | 6 ++- .github/workflows/build-device.yml | 18 ++++--- .github/workflows/build-image.yml | 10 +++- .github/workflows/build-tests.yml | 3 +- .github/workflows/on-pr.yml | 18 ------- .github/workflows/on-push.yml | 54 ------------------- .github/workflows/pre-commit.yml | 5 +- .github/workflows/run-tests.yml | 3 +- .github/workflows/test-runner.yaml | 12 ++++- 9 files changed, 40 insertions(+), 89 deletions(-) rename .github/workflows/{on-pr-opt.yml => build-and-run-all-tests.yml} (90%) delete mode 100644 .github/workflows/on-pr.yml delete mode 100644 .github/workflows/on-push.yml diff --git a/.github/workflows/on-pr-opt.yml b/.github/workflows/build-and-run-all-tests.yml similarity index 90% rename from .github/workflows/on-pr-opt.yml rename to .github/workflows/build-and-run-all-tests.yml index 18364734..ff75e6c2 100644 --- a/.github/workflows/on-pr-opt.yml +++ b/.github/workflows/build-and-run-all-tests.yml @@ -1,10 +1,12 @@ -# Optional PR checks -name: On PR - Optional +# Build and then run all tests, on all supported archs. +name: Build and run all tests on: workflow_dispatch: pull_request: branches: ["main"] + push: + branches: ["main"] jobs: build-tests: diff --git a/.github/workflows/build-device.yml b/.github/workflows/build-device.yml index 5a8c0648..335dd2c0 100644 --- a/.github/workflows/build-device.yml +++ b/.github/workflows/build-device.yml @@ -1,19 +1,19 @@ # Builds device. # Build is performed on all supported OS versions. -name: Build Target +name: Build Device on: - workflow_call: - inputs: - timeout: - required: true - type: number workflow_dispatch: inputs: timeout: required: true - description: 'The timeout for the build job in minutes' + description: 'The timeout for the job in minutes' type: number + default: 15 + pull_request: + branches: ["main"] + push: + branches: ["main"] env: BUILD_TARGET: device @@ -25,7 +25,9 @@ env: jobs: build: - timeout-minutes: ${{ inputs.timeout }} + # Due to parsing bug, fromJSON is used to convert string to number. + # In pull_request or push events, the input context is not available, stating the default again here. + timeout-minutes: ${{ fromJSON(inputs.timeout || '15') }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 3c21f65d..5affd5c2 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -3,11 +3,17 @@ name: Build and Publish Docker Image on: workflow_dispatch: - workflow_call: + inputs: + timeout: + required: true + description: 'The timeout for the job in minutes' + type: number + default: 15 jobs: build: - timeout-minutes: 15 + # Due to parsing bug, fromJSON is used to convert string to number + timeout-minutes: ${{ fromJSON(inputs.timeout) }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/build-tests.yml b/.github/workflows/build-tests.yml index 08dc84ee..3916e4bf 100644 --- a/.github/workflows/build-tests.yml +++ b/.github/workflows/build-tests.yml @@ -37,7 +37,8 @@ env: jobs: build: - timeout-minutes: ${{ inputs.timeout }} + # Due to parsing bug, fromJSON is used to convert string to number + timeout-minutes: ${{ fromJSON(inputs.timeout) }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/on-pr.yml b/.github/workflows/on-pr.yml deleted file mode 100644 index 158026dd..00000000 --- a/.github/workflows/on-pr.yml +++ /dev/null @@ -1,18 +0,0 @@ -# Mandatory PR checks -name: On PR - -on: - workflow_dispatch: - pull_request: - branches: ["main"] - -jobs: - build-all: - secrets: inherit - uses: ./.github/workflows/build-device.yml - with: - timeout: 15 - - pre-commit: - secrets: inherit - uses: ./.github/workflows/pre-commit.yml diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml deleted file mode 100644 index 673be510..00000000 --- a/.github/workflows/on-push.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: On Push - -on: - workflow_dispatch: - push: - branches: ["main"] - -jobs: - build-all: - secrets: inherit - uses: ./.github/workflows/build-device.yml - with: - timeout: 15 - - pre-commit: - secrets: inherit - uses: ./.github/workflows/pre-commit.yml - - build-tests: - secrets: inherit - strategy: - fail-fast: false - matrix: - test-group: [ - # Enable once we have functional cards with specified architecture. - {arch: grayskull}, - {arch: wormhole_b0}, - # {arch: blackhole}, - ] - uses: ./.github/workflows/build-tests.yml - with: - arch: ${{ matrix.test-group.arch }} - timeout: 15 - - test-all: - secrets: inherit - needs: build-tests - strategy: - fail-fast: false - matrix: - test-group: [ - # Enable once we have functional cards. - {arch: grayskull, card: e75, timeout: 10}, - {arch: grayskull, card: e150, timeout: 10}, - {arch: grayskull, card: e300, timeout: 10}, - {arch: wormhole_b0, card: n150, timeout: 5}, - {arch: wormhole_b0, card: n300, timeout: 15}, - # {arch: blackhole}, - ] - uses: ./.github/workflows/run-tests.yml - with: - arch: ${{ matrix.test-group.arch }} - card: ${{ matrix.test-group.card }} - timeout: ${{ matrix.test-group.timeout }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index a4ecb678..c4b2b9a0 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -2,8 +2,11 @@ name: Run Pre-commit Hooks on: - workflow_call: workflow_dispatch: + pull_request: + branches: ["main"] + push: + branches: ["main"] jobs: pre-commit: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 98b2a526..e9d1e6b2 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -45,7 +45,8 @@ env: jobs: test: - timeout-minutes: ${{ inputs.timeout }} + # Due to parsing bug, fromJSON is used to convert string to number + timeout-minutes: ${{ fromJSON(inputs.timeout) }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/test-runner.yaml b/.github/workflows/test-runner.yaml index 74a4d6bf..c871c773 100644 --- a/.github/workflows/test-runner.yaml +++ b/.github/workflows/test-runner.yaml @@ -2,10 +2,17 @@ name: Check runner on: workflow_dispatch: + inputs: + timeout: + required: true + description: 'The timeout for the job in minutes' + type: number + default: 10 jobs: check-runners-host: - timeout-minutes: 10 + # Due to parsing bug, fromJSON is used to convert string to number + timeout-minutes: ${{ fromJSON(inputs.timeout) }} strategy: fail-fast: false matrix: @@ -52,7 +59,8 @@ jobs: du -h --max-depth=1 | sort -rh check-runners-docker: - timeout-minutes: 10 + # Due to parsing bug, fromJSON is used to convert string to number + timeout-minutes: ${{ fromJSON(inputs.timeout) }} strategy: fail-fast: false matrix: