use github default environment variables #52
This file contains 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: Bazel CI | |
on: | |
push: | |
branches: [ "main" ] | |
paths-ignore: | |
- README.md | |
jobs: | |
executors: | |
name: Build & Push Executor Container Images | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
sparse-checkout: | | |
executors | |
- uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: docker/setup-buildx-action@v2 | |
- uses: docker/bake-action@v3 | |
with: | |
push: true | |
workdir: executors | |
set: | | |
*.cache-from=type=gha | |
*.cache-to=type=gha,mode=max | |
- name: Remove Untagged Container Images | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
set -x | |
gh api /user/packages?package_type=container | jq -r --arg repo $GITHUB_REPOSITORY '.[] | select(.repository.full_name == $repo) | .name' | tee $RUNNER_TEMP/names.txt | |
while read package | |
do | |
gh api /user/packages/container/${package//\//%2F}/versions | jq -r '.[] | select(.metadata.container.tags==[]) | .id' | tee $RUNNER_TEMP/ids.txt | |
while read id | |
do | |
echo gh api --method DELETE /user/packages/container/${package//\//%2F}/versions/${id} | |
done < $RUNNER_TEMP/ids.txt | |
done < $RUNNER_TEMP/names.txt | |
bazel: | |
name: Bazel Build & Test | |
runs-on: ubuntu-latest | |
needs: | |
- executors | |
steps: | |
- name: Bazel Home RC | |
run: | | |
echo "build --disk_cache=~/.cache/bazel.disk" >> ~/.bazelrc | |
echo "test --test_output=all" >> ~/.bazelrc | |
- uses: actions/cache@v3 | |
with: | |
path: ${{github.workspace}}/.cache/bazel.disk | |
key: bazel | |
- uses: actions/checkout@v3 | |
- name: Bazel Build with Docker | |
run: sudo runuser -u runner -g runner -G docker -- bazel build --config docker hellos tars rpms debs | |
- name: Bazel Host Tests | |
run: sudo runuser -u runner -g runner -G docker -- bazel test --config docker --strategy=TestRunner=sandboxed host-{hellos,tars}-test # We won't test the RPM and DEB tests on the host as they actually install the package. | |
- name: Bazel Docker Tests | |
run: sudo runuser -u runner -g runner -G docker -- bazel test --config docker --strategy=TestRunner=docker platform-{hello,tar,rpm,deb}-test-suite | |
- name: Work around https://github.com/actions/upload-artifact/issues/92 | |
run: echo "bazel_out=$(sudo runuser -u runner -g runner -G docker -- bazel info output_path)" >> $GITHUB_ENV | |
- run: sudo runuser -u runner -g runner -G docker -- bazel shutdown | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: ${{env.bazel_out}}/*/testlogs/** |