|
| 1 | +name: Build the application for all devices and upload the artifact |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + app_repository: |
| 7 | + description: 'The GIT repository to build (defaults to `github.repository`)' |
| 8 | + required: false |
| 9 | + default: ${{ github.repository }} |
| 10 | + type: string |
| 11 | + app_branch_name: |
| 12 | + description: 'The GIT branch to build (defaults to `github.ref`)' |
| 13 | + required: false |
| 14 | + default: ${{ github.ref }} |
| 15 | + type: string |
| 16 | + run_for_devices: |
| 17 | + description: | |
| 18 | + The list of device(s) on which the CI will run. |
| 19 | +
|
| 20 | + Defaults to the full list of device(s) supported by the application as configured in the |
| 21 | + 'ledger_app.toml' manifest. |
| 22 | + If the manifest is missing, defaults to ALL (["nanos", "nanox", "nanosp", "stax", "flex", "apex_m", "apex_p"]). |
| 23 | + required: false |
| 24 | + default: 'None' |
| 25 | + type: string |
| 26 | + builder: |
| 27 | + description: "The docker image to build the application in (defaults to ledger-app-builder-lite)" |
| 28 | + required: false |
| 29 | + default: 'ledger-app-builder-lite' |
| 30 | + type: string |
| 31 | + flags: |
| 32 | + description: "Additional flags (default to none)" |
| 33 | + required: false |
| 34 | + default: '' |
| 35 | + type: string |
| 36 | + |
| 37 | +jobs: |
| 38 | + call_get_app_metadata: |
| 39 | + # This job digests inputs and repository metadata provided by the `ledger_app.toml` manifest |
| 40 | + # file, in order to output relevant compatible devices needed by following jobs. |
| 41 | + name: Retrieve application metadata |
| 42 | + uses: ./.github/workflows/_get_app_metadata.yml |
| 43 | + with: |
| 44 | + app_repository: ${{ inputs.app_repository }} |
| 45 | + app_branch_name: ${{ inputs.app_branch_name }} |
| 46 | + compatible_devices: ${{ inputs.run_for_devices }} |
| 47 | + secrets: |
| 48 | + token: ${{ secrets.token }} |
| 49 | + |
| 50 | + build_device_matrix: |
| 51 | + name: Build device matrix |
| 52 | + needs: call_get_app_metadata |
| 53 | + runs-on: ubuntu-latest |
| 54 | + outputs: |
| 55 | + sdks_config: ${{ steps.sdk_list.outputs.sdks_config }} |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Define the list of devices to target |
| 59 | + id: sdk_list |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + if [ "${{ inputs.run_for_devices }}" = "None" ]; then |
| 63 | + # Use the compatible devices from metadata |
| 64 | + devices_json='${{ needs.call_get_app_metadata.outputs.compatible_devices }}' |
| 65 | + else |
| 66 | + # Convert space-separated string to JSON array |
| 67 | + devices_string="${{ inputs.run_for_devices }}" |
| 68 | + devices_json=$(echo "${devices_string}" | jq -R 'split(" ")') |
| 69 | + fi |
| 70 | +
|
| 71 | + # Generate SDK environment variables from device names |
| 72 | + sdks_json=$(echo "${devices_json}" | jq -c 'map("$" + (. | ascii_upcase) + "_SDK")') |
| 73 | +
|
| 74 | + echo "sdks_config=${sdks_json}" >> "$GITHUB_OUTPUT" |
| 75 | +
|
| 76 | + - name: Print devices and SDKs |
| 77 | + run: | |
| 78 | + echo "SDKs: ${{ steps.sdk_list.outputs.sdks_config }}" |
| 79 | +
|
| 80 | + analyse: |
| 81 | + name: Analyse application |
| 82 | + needs: build_device_matrix |
| 83 | + strategy: |
| 84 | + fail-fast: false |
| 85 | + matrix: |
| 86 | + sdk: ${{ fromJSON(needs.build_device_matrix.outputs.sdks_config) }} |
| 87 | + # 'cpp' covers C and C++ |
| 88 | + language: ['cpp'] |
| 89 | + runs-on: ubuntu-latest |
| 90 | + container: |
| 91 | + image: ghcr.io/ledgerhq/ledger-app-builder/${{ inputs.builder }}:latest |
| 92 | + |
| 93 | + steps: |
| 94 | + - name: Clone |
| 95 | + uses: actions/checkout@v4 |
| 96 | + with: |
| 97 | + repository: ${{ inputs.app_repository }} |
| 98 | + ref: ${{ inputs.app_branch_name }} |
| 99 | + submodules: recursive |
| 100 | + token: ${{ secrets.token && secrets.token || github.token }} |
| 101 | + |
| 102 | + - name: Initialize CodeQL |
| 103 | + uses: github/codeql-action/init@v3 |
| 104 | + with: |
| 105 | + languages: ${{ matrix.language }} |
| 106 | + queries: security-and-quality |
| 107 | + |
| 108 | + # CodeQL will create the database during the compilation |
| 109 | + - name: Build |
| 110 | + run: | |
| 111 | + ${{ inputs.flags }} make BOLOS_SDK=${{ matrix.sdk }} |
| 112 | +
|
| 113 | + - name: Perform CodeQL Analysis |
| 114 | + uses: github/codeql-action/analyze@v3 |
0 commit comments