|
| 1 | +name: Check-Build-Firmware |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [opened, synchronize, edited] |
| 6 | + |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + branch: |
| 10 | + description: 'Branch to test' |
| 11 | + type: string |
| 12 | + default: 'master' |
| 13 | + |
| 14 | +env: |
| 15 | + SL_SLC_PATH: ${{ github.workspace }}/tools/slc_cli/slc |
| 16 | + CI_REPO_DIR: ${{ github.workspace }}/application_examples_ci |
| 17 | + SL_STUDIO_BUILD_PATH: ${{ github.workspace }}/tools/SimplicityStudio_v5 |
| 18 | + STUDIO_ADAPTER_PACK_PATH: ${{ github.workspace }}/tools/SimplicityStudio_v5/developer/adapter_packs |
| 19 | + POST_BUILD_EXE: ${{ github.workspace }}/tools/SimplicityStudio_v5/developer/adapter_packs/commander/commander |
| 20 | + WORKSPACE: ${{ github.workspace }} |
| 21 | + SKIP_TEST: false |
| 22 | + |
| 23 | +jobs: |
| 24 | + build_firmware: |
| 25 | + runs-on: ubuntu-22.04 |
| 26 | + steps: |
| 27 | + - name: Trigger |
| 28 | + run: echo "Triggered by ${{github.event_name}} event" |
| 29 | + - name: Check Branch Input |
| 30 | + run: | |
| 31 | + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then |
| 32 | + if [ -z "${{ github.event.inputs.branch }}" ]; then |
| 33 | + echo "Branch input is required for manual trigger." |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | + fi |
| 37 | + - name: Get repository name |
| 38 | + run: | |
| 39 | + REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d "/" -f 2) |
| 40 | + echo "repo=$REPO_NAME" >> $GITHUB_ENV |
| 41 | + - name: Create GitHub App Token |
| 42 | + id: app-token |
| 43 | + uses: actions/create-github-app-token@v1 |
| 44 | + with: |
| 45 | + app-id: ${{ vars.GH_APP_ID }} |
| 46 | + private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} |
| 47 | + owner: ${{ github.repository_owner }} |
| 48 | + - name: Checkout tools repository |
| 49 | + uses: actions/checkout@v4 |
| 50 | + with: |
| 51 | + repository: SiliconLabsSoftware/aep_ci_tools |
| 52 | + ref: 'hop_dev' |
| 53 | + token: ${{ steps.app-token.outputs.token }} |
| 54 | + path: 'aep_ci_tools' |
| 55 | + - name: Checkout base repository code |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + token: ${{ steps.app-token.outputs.token }} |
| 59 | + path: 'projects' |
| 60 | + - name: Checkout head ref |
| 61 | + # This is necessary to check the changes in the PR branch |
| 62 | + run: | |
| 63 | + cd projects |
| 64 | + git fetch origin ${{ github.base_ref }}:base_ref |
| 65 | + git fetch origin pull/${{ github.event.pull_request.number }}/head:pr_ref |
| 66 | + git checkout ${{ github.event.pull_request.head.sha }} |
| 67 | + - name: Check the changes |
| 68 | + run: | |
| 69 | + cd projects |
| 70 | + git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ |
| 71 | + --diff-filter=ACMR --name-only > git_diff.txt |
| 72 | + echo ===============Changed files:================ |
| 73 | + cat git_diff.txt |
| 74 | + echo ============================================= |
| 75 | + git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} \ |
| 76 | + --diff-filter=ACMR --name-only | grep '/' | cut -d'/' -f1 | sort | uniq > git_log.txt |
| 77 | + if [ -s git_log.txt ]; then |
| 78 | + grep -v "deprecated" git_log.txt > changed_projects_folder.txt |
| 79 | + fi |
| 80 | + if [ ! -f changed_projects_folder.txt ] || [ ! -s changed_projects_folder.txt ]; then |
| 81 | + echo ============================================= |
| 82 | + echo "No project changes detected...........Skipped" |
| 83 | + echo ============================================= |
| 84 | + echo "SKIP_TEST=true" >> $GITHUB_ENV |
| 85 | + exit 0 |
| 86 | + fi |
| 87 | + echo ================Changed projects:============= |
| 88 | + cat changed_projects_folder.txt |
| 89 | + echo ============================================== |
| 90 | + - name: Setup Java |
| 91 | + if: ${{ env.SKIP_TEST == 'false' }} |
| 92 | + uses: actions/setup-java@v4 |
| 93 | + with: |
| 94 | + distribution: 'oracle' |
| 95 | + java-version: '21' |
| 96 | + - name: Install Dependencies |
| 97 | + if: ${{ env.SKIP_TEST == 'false' }} |
| 98 | + run: bash ${{ github.workspace }}/aep_ci_tools/scripts/install_tools.sh |
| 99 | + - name: Run build the projects |
| 100 | + if: ${{ env.SKIP_TEST == 'false' }} |
| 101 | + run : | |
| 102 | + mkdir changed_projects |
| 103 | + while read line; do cp -r ./projects/$line --parents ./changed_projects; \ |
| 104 | + done < ${{ github.workspace}}/projects/changed_projects_folder.txt |
| 105 | + python3 -u ${{ github.workspace}}/aep_ci_tools/scripts/checkproject.py --junit \ |
| 106 | + --html --release --slcpgcc ${{ github.workspace}}/changed_projects |
| 107 | + - name: Upload Result |
| 108 | + if: ${{ env.SKIP_TEST == 'false' }} |
| 109 | + uses: actions/upload-artifact@v4 |
| 110 | + with: |
| 111 | + name: build_test_project |
| 112 | + path: build_test_project.html |
| 113 | + retention-days: 90 |
| 114 | + - name: Check log file to set status of the job |
| 115 | + if: ${{ env.SKIP_TEST == 'false' }} |
| 116 | + run: | |
| 117 | + if grep -qe "Fail" build_test_project.html; then |
| 118 | + echo ======================================= |
| 119 | + echo "Result: Failure" |
| 120 | + echo "Check report at the step: Upload Result" |
| 121 | + echo ======================================= |
| 122 | + exit 1 |
| 123 | + else |
| 124 | + echo "Result: Success" |
| 125 | + fi |
0 commit comments