From 246302571d92005fe8125e7830a7907faf92c661 Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Mon, 3 Oct 2022 17:33:22 +0200 Subject: [PATCH 1/3] Use a matrix to build all platforms --- .github/workflows/CI.yml | 81 ++++++++-------------------------------- 1 file changed, 16 insertions(+), 65 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 572a599226..f547bf2451 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,68 +14,19 @@ permissions: contents: read jobs: - cf2: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - submodules: true - - name: build - run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make defconfig && ./tools/build/build UNIT_TEST_STYLE=min" - - name: Upload Build Artifact - uses: actions/upload-artifact@v2.1.4 - with: - name: cf2-${{ github.sha }} - path: | - cf2.bin - cf2.elf - - bolt: + basic_build: + needs: read_targets_from_file runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - submodules: true - - - name: build - run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make bolt_defconfig && ./tools/build/build UNIT_TEST_STYLE=min" - - - name: Upload Build Artifact - uses: actions/upload-artifact@v2.1.4 - with: - name: bolt-${{ github.sha }} - path: | - bolt.bin - bolt.elf - - tag: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - submodules: true - - - name: build - run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make tag_defconfig && ./tools/build/build UNIT_TEST_STYLE=min" - - - name: Upload Build Artifact - uses: actions/upload-artifact@v2.1.4 - with: - name: tag-${{ github.sha }} - path: | - tag.bin - tag.elf - - cfbl: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: + - cf2 + - bolt + - tag steps: - name: Checkout Repo @@ -84,19 +35,19 @@ jobs: submodules: true - name: build - run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make cfbl_defconfig && ./tools/build/build UNIT_TEST_STYLE=min" + run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make ${{ matrix.platform }}_defconfig && ./tools/build/build UNIT_TEST_STYLE=min" - name: Upload Build Artifact uses: actions/upload-artifact@v2.1.4 with: - name: cfbl-${{ github.sha }} + name: ${{ matrix.platform }}-${{ github.sha }} path: | - cfbl.bin - cfbl.elf + ${{ matrix.platform }}.bin + ${{ matrix.platform }}.elf features: runs-on: ubuntu-latest - needs: cf2 + needs: basic_build strategy: fail-fast: false @@ -132,7 +83,7 @@ jobs: apps: runs-on: ubuntu-latest - needs: cf2 + needs: basic_build strategy: fail-fast: false @@ -160,7 +111,7 @@ jobs: kbuild-targets: runs-on: ubuntu-latest - needs: cf2 + needs: basic_build strategy: fail-fast: false From 90a3b0e5596f831fd2d91035d1f9c830f14f243f Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Mon, 3 Oct 2022 17:37:25 +0200 Subject: [PATCH 2/3] Use file to define build targets --- .github/workflows/CI.yml | 24 +++++++++++++++--- .github/workflows/release.yml | 46 ++++++++++++++++++++++++++--------- build_targets.json | 7 ++++++ module.json | 11 --------- 4 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 build_targets.json diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index f547bf2451..c227285887 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -14,7 +14,26 @@ permissions: contents: read jobs: + read_targets_from_file: + runs-on: ubuntu-latest + outputs: + platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + submodules: false + + - id: read-build-target-from-file + run: | + content=`cat ./build_targets.json` + # the following lines are required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of handling for multi line json + echo "::set-output name=platforms::$content" basic_build: needs: read_targets_from_file @@ -23,10 +42,7 @@ jobs: strategy: fail-fast: false matrix: - platform: - - cf2 - - bolt - - tag + ${{fromJson(needs.read_targets_from_file.outputs.platforms)}} steps: - name: Checkout Repo diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0ee715585..d77eb22f24 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,10 +9,32 @@ permissions: contents: read jobs: + read_targets_from_file: + runs-on: ubuntu-latest + outputs: + platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + submodules: false + + - id: read-build-target-from-file + run: | + content=`cat ./build_targets.json` + # the following lines are required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of handling for multi line json + echo "::set-output name=platforms::$content" + release: permissions: contents: write # for actions/create-release to create a release name: Create Release on Github + needs: read_targets_from_file runs-on: ubuntu-latest steps: - name: Create Release @@ -31,7 +53,7 @@ jobs: uses: actions/upload-artifact@v1 with: name: release_url - path: release_url.txt + path: release_url.txt upload: permissions: @@ -42,8 +64,8 @@ jobs: strategy: fail-fast: false matrix: - platforms: [cf2, tag, bolt] - + ${{fromJson(needs.read_targets_from_file.outputs.platforms)}} + steps: - name: Checkout Repo uses: actions/checkout@v2 @@ -51,7 +73,7 @@ jobs: submodules: true - name: Build - run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make ${{ matrix.platforms }}_defconfig && ./tools/build/build PLATFORM=${{ matrix.platforms }} UNIT_TEST_STYLE=min" + run: docker run --rm -v ${PWD}:/module bitcraze/builder bash -c "make ${{ matrix.platform }}_defconfig && ./tools/build/build PLATFORM=${{ matrix.platform }} UNIT_TEST_STYLE=min" - name: Load Release URL File from release job uses: actions/download-artifact@v1 @@ -63,19 +85,19 @@ jobs: run: | value=`cat release_url/release_url.txt` echo ::set-output name=upload_url::$value - - - name: Get the version - id: get_release_version - env: + + - name: Get the version + id: get_release_version + env: GITHUB_REF : ${{ github.ref }} run: echo ::set-output name=release_version::${GITHUB_REF/refs\/tags\//} - - - name: Upload ${{ matrix.platforms }} bin + + - name: Upload ${{ matrix.platform }} bin uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ steps.get_release_info.outputs.upload_url }} - asset_path: ${{ matrix.platforms }}.bin - asset_name: ${{ matrix.platforms }}-${{ steps.get_release_version.outputs.release_version }}.bin + asset_path: ${{ matrix.platform }}.bin + asset_name: ${{ matrix.platform }}-${{ steps.get_release_version.outputs.release_version }}.bin asset_content_type: application/octet-stream diff --git a/build_targets.json b/build_targets.json new file mode 100644 index 0000000000..3857ea63bd --- /dev/null +++ b/build_targets.json @@ -0,0 +1,7 @@ +{ + "platform" : [ + "cf2", + "bolt", + "tag" + ] + } diff --git a/module.json b/module.json index 7890dc6b51..92eae26e05 100644 --- a/module.json +++ b/module.json @@ -3,16 +3,5 @@ "environmentReqs": { "build": ["arm-none-eabi"], "build-docs": ["doxygen"] - }, - "actions": { - "artifacts": [ - ".bin", - ".dfu" - ], - "targets" : [ - "cf2", - "bolt", - "tag" - ] } } From 043230df318f8256c0345465d9898f78cd3aaf68 Mon Sep 17 00:00:00 2001 From: Kristoffer Richardsson Date: Tue, 4 Oct 2022 06:51:40 +0200 Subject: [PATCH 3/3] Moved file reading to a reusable workflow --- .github/workflows/CI.yml | 20 +----------- .github/workflows/read_build_targets.yml | 39 ++++++++++++++++++++++++ .github/workflows/release.yml | 20 +----------- 3 files changed, 41 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/read_build_targets.yml diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index c227285887..0febbc4476 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -15,25 +15,7 @@ permissions: jobs: read_targets_from_file: - runs-on: ubuntu-latest - outputs: - platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} - - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - submodules: false - - - id: read-build-target-from-file - run: | - content=`cat ./build_targets.json` - # the following lines are required for multi line json - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - # end of handling for multi line json - echo "::set-output name=platforms::$content" + uses: ./.github/workflows/read_build_targets.yml basic_build: needs: read_targets_from_file diff --git a/.github/workflows/read_build_targets.yml b/.github/workflows/read_build_targets.yml new file mode 100644 index 0000000000..0c644a5461 --- /dev/null +++ b/.github/workflows/read_build_targets.yml @@ -0,0 +1,39 @@ +# This work flow checks out the repo and reads the list of release targets from +# the build_targetst.json file. + +# The list of targets is available in needs.read_targets_from_file.outputs.platforms as a json dictionary, use it +# in matrix like this: ${{fromJson(needs.read_targets_from_file.outputs.platforms)}} + +name: Read build targets + +on: + workflow_call: + outputs: + platforms: + description: "'platform' is set to the list of targets" + value: ${{ jobs.read_targets_from_file.outputs.platforms }} + +permissions: + contents: read + +jobs: + read_targets_from_file: + runs-on: ubuntu-latest + outputs: + platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} + + steps: + - name: Checkout Repo + uses: actions/checkout@v2 + with: + submodules: false + + - id: read-build-target-from-file + run: | + content=`cat ./build_targets.json` + # the following lines are required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of handling for multi line json + echo "::set-output name=platforms::$content" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d77eb22f24..c613e208bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,25 +10,7 @@ permissions: jobs: read_targets_from_file: - runs-on: ubuntu-latest - outputs: - platforms: ${{ steps.read-build-target-from-file.outputs.platforms }} - - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - with: - submodules: false - - - id: read-build-target-from-file - run: | - content=`cat ./build_targets.json` - # the following lines are required for multi line json - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - # end of handling for multi line json - echo "::set-output name=platforms::$content" + uses: ./.github/workflows/read_build_targets.yml release: permissions: