CI #581
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: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| artifacts: | |
| name: "Artifacts" | |
| runs-on: ubuntu-22.04 | |
| env: | |
| SPINE: pi3hat_spine | |
| SPINE_PATH: ./bazel-out/aarch64-opt/bin/spines/ | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Install dependencies" | |
| run: | | |
| sudo apt install libncurses5 | |
| - name: "Build pi3hat spine artifact" | |
| run: | | |
| tools/bazelisk build --verbose_failures --config=pi64 //spines:pi3hat_spine | |
| - name: "Prepare artifacts directory" | |
| run: | | |
| mkdir -p artifacts && mv ${{ env.SPINE_PATH }}${{ env.SPINE }} ./artifacts/ | |
| - name: "Upload artifacts" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.SPINE }} | |
| path: ./artifacts | |
| build_linux: | |
| name: "Build on Linux" | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: "Build all targets" | |
| env: | |
| BAZELISK_GITHUB_TOKEN: ${{ secrets.BAZELISK_GITHUB_TOKEN }} | |
| run: | | |
| tools/bazelisk build --compilation_mode=fastbuild //... | |
| build_darwin_arm64: | |
| name: "Build on macOS (ARM64)" | |
| runs-on: macos-latest | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: 'Set up latest Oracle JDK 21' | |
| uses: oracle-actions/setup-java@v1 | |
| with: | |
| website: oracle.com | |
| release: 21 | |
| - name: "Build all targets" | |
| run: | | |
| tools/bazelisk build --compilation_mode=fastbuild --config=darwin_arm64 //... | |
| build_darwin_x86: | |
| name: "Build on macOS (x86)" | |
| runs-on: macos-13 | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: 'Set up latest Oracle JDK 21' | |
| uses: oracle-actions/setup-java@v1 | |
| with: | |
| website: oracle.com | |
| release: 21 | |
| - name: "Build all targets" | |
| run: | | |
| tools/bazelisk build --compilation_mode=fastbuild --config=darwin_x86 //... | |
| build_raspi: | |
| name: "Cross-compile to the Raspberry Pi" | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Install dependencies" | |
| run: | | |
| # See https://github.com/orgs/upkie/discussions/42 | |
| sudo apt install libtinfo5 | |
| - name: "Build Raspberry Pi targets" | |
| env: | |
| BAZELISK_GITHUB_TOKEN: ${{ secrets.BAZELISK_GITHUB_TOKEN }} | |
| run: | | |
| make build | |
| coverage: | |
| name: "Coverage" | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Setup Python environment" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: "Install dependencies" | |
| run: | | |
| pip install gymnasium loop-rate-limiters msgpack numpy scipy upkie_description | |
| - name: "Test coverage" | |
| run: | | |
| tools/bazelisk coverage --combined_report=lcov --compilation_mode=fastbuild --instrument_test_targets //... | |
| - name: "Submit report to Coveralls" | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.github_token }} | |
| file: ${{ github.workspace }}/bazel-out/_coverage/_coverage_report.dat | |
| format: lcov | |
| lint: | |
| name: "Lint code" | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Setup Python environment" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: "Install dependencies" | |
| run: pip install ruff six | |
| - name: "Check code formatting" | |
| env: | |
| BAZELISK_GITHUB_TOKEN: ${{ secrets.BAZELISK_GITHUB_TOKEN }} | |
| run: | | |
| tools/bazelisk test --compilation_mode=fastbuild --config lint //... | |
| - name: "Check Python code formatting" | |
| run: | | |
| ruff check upkie | |
| - name: "Check shell scripts formatting" | |
| run: | | |
| find . \ | |
| -type f \ | |
| -not \( -path '*/.git/*' -prune \) \ | |
| -not \( -path '*/wiki/*' -prune \) \ | |
| -exec sh -c 'head -n 1 {} | grep -q "#!/.*sh"' {} \; \ | |
| -exec shellcheck {} \; | |
| test: | |
| name: "Test on Linux with Python ${{ matrix.python-version }}" | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| defaults: | |
| run: | |
| # See https://github.com/mamba-org/setup-micromamba?tab=readme-ov-file#about-login-shells | |
| shell: bash -leo pipefail {0} | |
| steps: | |
| - name: "Checkout sources" | |
| uses: actions/checkout@v4 | |
| - name: "Install Conda environment with Micromamba" | |
| uses: mamba-org/setup-micromamba@v1 | |
| with: | |
| micromamba-version: '1.5.8-0' | |
| environment-name: upkie_test_env | |
| create-args: >- | |
| python=${{ matrix.python-version }} | |
| gymnasium | |
| loop-rate-limiters | |
| msgpack-python | |
| numpy | |
| scipy | |
| stable-baselines3>2.3.0 | |
| upkie_description | |
| cache-environment: true | |
| post-cleanup: 'all' | |
| - name: "Check unit tests" | |
| env: | |
| BAZELISK_GITHUB_TOKEN: ${{ secrets.BAZELISK_GITHUB_TOKEN }} | |
| run: | | |
| tools/bazelisk test --compilation_mode=fastbuild //... | |
| ci_success: | |
| name: "CI success" | |
| runs-on: ubuntu-22.04 | |
| needs: | |
| - artifacts | |
| - build_darwin_arm64 | |
| - build_darwin_x86 | |
| - build_linux | |
| - build_raspi | |
| - coverage | |
| - lint | |
| - test | |
| steps: | |
| - run: echo "CI workflow completed successfully" |