ci test #2316
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags-ignore: | |
| - '**' | |
| jobs: | |
| devcontainer: | |
| name: Devcontainer image | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_name: ${{ steps.image.outputs.name }} | |
| image_tag: ${{ steps.image.outputs.tag }} | |
| steps: | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup image metadata | |
| id: image | |
| run: | | |
| set -euo pipefail | |
| echo "name=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}/opendeck-devcontainer" >> "${GITHUB_OUTPUT}" | |
| echo "tag=ci-${{ hashFiles('.devcontainer/Dockerfile', '.devcontainer/devcontainer.json', '.devcontainer/ci/devcontainer.json') }}" >> "${GITHUB_OUTPUT}" | |
| - name: Check image | |
| id: image-exists | |
| run: | | |
| set -euo pipefail | |
| if docker manifest inspect "${{ steps.image.outputs.name }}:${{ steps.image.outputs.tag }}" >/dev/null 2>&1; then | |
| echo "exists=true" >> "${GITHUB_OUTPUT}" | |
| else | |
| echo "exists=false" >> "${GITHUB_OUTPUT}" | |
| fi | |
| - name: Build and push container | |
| if: steps.image-exists.outputs.exists != 'true' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: .devcontainer | |
| file: .devcontainer/Dockerfile | |
| push: true | |
| tags: ${{ steps.image.outputs.name }}:${{ steps.image.outputs.tag }} | |
| app-targets: | |
| name: App targets | |
| runs-on: ubuntu-latest | |
| outputs: | |
| targets: ${{ steps.targets.outputs.targets }} | |
| steps: | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: List app targets | |
| id: targets | |
| run: | | |
| set -euo pipefail | |
| targets=$(./scripts/bulk_build.sh --type=app --print-target-matrix) | |
| echo "targets=${targets}" >> "${GITHUB_OUTPUT}" | |
| app: | |
| name: App (${{ matrix.target }}) | |
| runs-on: ubuntu-latest | |
| needs: | |
| - app-targets | |
| - devcontainer | |
| container: &native-container | |
| image: ${{ needs.devcontainer.outputs.image_name }}:${{ needs.devcontainer.outputs.image_tag }} | |
| credentials: | |
| username: ${{ github.repository_owner }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| options: --user root | |
| env: &native-env | |
| HOME: /home/ubuntu | |
| defaults: &native-defaults | |
| run: | |
| shell: bash | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJson(needs.app-targets.outputs.targets) }} | |
| steps: | |
| - name: Free Disk Space | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Prepare zenv | |
| uses: ./.github/actions/prepare-zenv-native | |
| - name: Setup ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: app-${{ matrix.target }} | |
| restore-keys: app-${{ matrix.target }} | |
| max-size: 1G | |
| - name: Build target | |
| run: | | |
| set -euo pipefail | |
| git fetch --tags | |
| git rev-parse HEAD | |
| git status --short | |
| make TARGET=${{ matrix.target }} | |
| ./scripts/copy_release_binaries.sh --build-dir=build --copy-dir=release/${{ matrix.target }} | |
| test -n "$(find release/${{ matrix.target }} -type f -print -quit)" | |
| cd release/${{ matrix.target }} | |
| python3 -m zipfile -c ../../release-${{ matrix.target }}.zip * | |
| - name: Upload release binaries | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: release-${{ matrix.target }} | |
| path: release-${{ matrix.target }}.zip | |
| if-no-files-found: error | |
| host-test-targets: | |
| name: Host test targets | |
| runs-on: ubuntu-latest | |
| outputs: | |
| targets: ${{ steps.targets.outputs.targets }} | |
| steps: | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: List host test targets | |
| id: targets | |
| run: | | |
| set -euo pipefail | |
| targets=$(./scripts/bulk_build.sh --type=host-test --print-target-matrix) | |
| echo "targets=${targets}" >> "${GITHUB_OUTPUT}" | |
| host-test-shared: | |
| name: Tests (shared) | |
| runs-on: ubuntu-latest | |
| needs: | |
| - host-test-targets | |
| - devcontainer | |
| container: *native-container | |
| env: *native-env | |
| defaults: *native-defaults | |
| steps: | |
| - name: Free Disk Space | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Prepare zenv | |
| uses: ./.github/actions/prepare-zenv-native | |
| - name: Setup ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: host-test-shared | |
| restore-keys: host-test-shared | |
| max-size: 1G | |
| - name: Run shared host tests | |
| run: | | |
| set -euo pipefail | |
| ./scripts/bulk_build.sh --type=host-test --test-scope=shared | |
| host-test-target: | |
| name: Tests (${{ matrix.target }}) | |
| runs-on: ubuntu-latest | |
| needs: | |
| - host-test-targets | |
| - devcontainer | |
| container: *native-container | |
| env: *native-env | |
| defaults: *native-defaults | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJson(needs.host-test-targets.outputs.targets) }} | |
| steps: | |
| - name: Free Disk Space | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Prepare zenv | |
| uses: ./.github/actions/prepare-zenv-native | |
| - name: Setup ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: host-test-${{ matrix.target }} | |
| restore-keys: host-test-${{ matrix.target }} | |
| max-size: 1G | |
| - name: Run host test | |
| run: | | |
| set -euo pipefail | |
| make configure-app TARGET=${{ matrix.target }} | |
| ./scripts/bulk_build.sh --type=host-test --test-scope=preset --test-target=${{ matrix.target }} | |
| format: | |
| name: Code formatting | |
| runs-on: ubuntu-latest | |
| needs: devcontainer | |
| container: *native-container | |
| env: *native-env | |
| defaults: *native-defaults | |
| steps: | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Prepare zenv | |
| uses: ./.github/actions/prepare-zenv-native | |
| - name: Check formatting | |
| run: make format | |
| lint-targets: | |
| name: Lint targets | |
| runs-on: ubuntu-latest | |
| outputs: | |
| targets: ${{ steps.targets.outputs.targets }} | |
| steps: | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: List lint targets | |
| id: targets | |
| run: | | |
| set -euo pipefail | |
| targets=$(./scripts/bulk_build.sh --type=lint --print-target-matrix) | |
| echo "targets=${targets}" >> "${GITHUB_OUTPUT}" | |
| lint: | |
| name: Lint (${{ matrix.target }}) | |
| runs-on: ubuntu-latest | |
| needs: | |
| - lint-targets | |
| - devcontainer | |
| container: *native-container | |
| env: *native-env | |
| defaults: *native-defaults | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| target: ${{ fromJson(needs.lint-targets.outputs.targets) }} | |
| steps: | |
| - name: Free Disk Space | |
| uses: jlumbroso/free-disk-space@main | |
| with: | |
| tool-cache: false | |
| android: true | |
| dotnet: true | |
| haskell: true | |
| - name: Pull the repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Prepare zenv | |
| uses: ./.github/actions/prepare-zenv-native | |
| - name: Setup ccache | |
| uses: hendrikmuhs/ccache-action@v1.2 | |
| with: | |
| key: lint-${{ matrix.target }} | |
| restore-keys: lint-${{ matrix.target }} | |
| max-size: 1G | |
| - name: Run lint | |
| run: | | |
| set -euo pipefail | |
| make CHECK=1 TARGET=${{ matrix.target }} |