Skip to content

Commit

Permalink
Merge pull request #1125 from bitcraze/krichardsson/ci-targets-in-file
Browse files Browse the repository at this point in the history
Use a file to define build targets
  • Loading branch information
krichardsson authored Oct 4, 2022
2 parents b370e20 + 043230d commit 17b609e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 89 deletions.
81 changes: 15 additions & 66 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,17 @@ 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/[email protected]
with:
name: cf2-${{ github.sha }}
path: |
cf2.bin
cf2.elf
bolt:
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/[email protected]
with:
name: bolt-${{ github.sha }}
path: |
bolt.bin
bolt.elf
read_targets_from_file:
uses: ./.github/workflows/read_build_targets.yml

tag:
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 tag_defconfig && ./tools/build/build UNIT_TEST_STYLE=min"

- name: Upload Build Artifact
uses: actions/[email protected]
with:
name: tag-${{ github.sha }}
path: |
tag.bin
tag.elf
cfbl:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
${{fromJson(needs.read_targets_from_file.outputs.platforms)}}

steps:
- name: Checkout Repo
Expand All @@ -84,19 +33,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/[email protected]
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
Expand Down Expand Up @@ -132,7 +81,7 @@ jobs:

apps:
runs-on: ubuntu-latest
needs: cf2
needs: basic_build

strategy:
fail-fast: false
Expand Down Expand Up @@ -160,7 +109,7 @@ jobs:

kbuild-targets:
runs-on: ubuntu-latest
needs: cf2
needs: basic_build

strategy:
fail-fast: false
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/read_build_targets.yml
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 16 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@ permissions:
contents: read

jobs:
read_targets_from_file:
uses: ./.github/workflows/read_build_targets.yml

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
Expand All @@ -31,7 +35,7 @@ jobs:
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt
path: release_url.txt

upload:
permissions:
Expand All @@ -42,16 +46,16 @@ 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
with:
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
Expand All @@ -63,19 +67,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
7 changes: 7 additions & 0 deletions build_targets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"platform" : [
"cf2",
"bolt",
"tag"
]
}
11 changes: 0 additions & 11 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,5 @@
"environmentReqs": {
"build": ["arm-none-eabi"],
"build-docs": ["doxygen"]
},
"actions": {
"artifacts": [
".bin",
".dfu"
],
"targets" : [
"cf2",
"bolt",
"tag"
]
}
}

0 comments on commit 17b609e

Please sign in to comment.