[ci] Update github caching to be more similar to drake-blender #821
Workflow file for this run
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 ROS 2 rules Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches: | |
- main | |
- develop | |
jobs: | |
bazel_build_and_test: | |
if: "! contains(github.event.pull_request.labels.*.name, 'status: defer ci')" | |
runs-on: ubuntu-latest | |
container: | |
image: ros:rolling-ros-base-jammy | |
# This is required for running lldb. | |
# See https://stackoverflow.com/a/73613377/7829525 | |
options: --cap-add=SYS_PTRACE --security-opt seccomp=unconfined | |
steps: | |
- uses: actions/checkout@v3 | |
# Caching. See comments in drake-blender for more details: | |
# https://github.com/RobotLocomotion/drake-blender/blob/c4a33f80/.github/workflows/main.yml | |
- uses: actions/cache/restore@v3 | |
with: | |
path: "/home/runner/.cache/bazel_ci" | |
# We want this key to change to ensure we store the updated cache. | |
key: bazel_ci-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }} | |
restore-keys: | | |
bazel_ci-${{ github.ref }}- | |
bazel_ci-refs/heads/main- | |
- name: Check cache | |
run: du -hs $(readlink -f /home/runner/.cache/bazel_ci) || true | |
# Setup. | |
- name: Simplify apt upgrades | |
run: .github/simplify_apt_and_upgrades.sh | |
- name: Configure Bazel for CI (bazel_ros2_rules) | |
run: ln -s ../.github/ci.bazelrc ./user.bazelrc | |
working-directory: bazel_ros2_rules | |
- name: Configure Bazel for CI (ros2_example_bazel_installed) | |
run: ln -s ../.github/ci.bazelrc ./user.bazelrc | |
working-directory: ros2_example_bazel_installed | |
- name: Install prerequisites | |
run: yes | ./setup/install_prereqs.sh | |
working-directory: ros2_example_bazel_installed | |
# Place this before main build. | |
# TODO(eric.cousineau): Remove this pending resolution of #107. | |
- name: Check direct runs via runfiles | |
run: ./setup/runfiles_direct_test.sh | |
working-directory: ros2_example_bazel_installed | |
- name: Test lint | |
run: ./fix_bazel_lint.sh --test | |
working-directory: . | |
- name: Build Bazel workspace (bazel_ros2_rules) | |
run: bazel build //... | |
working-directory: bazel_ros2_rules | |
- name: Test Bazel workspace (bazel_ros2_rules) | |
run: bazel test //... | |
working-directory: bazel_ros2_rules | |
- name: Build Bazel workspace (ros2_example_installed) | |
run: bazel build //... | |
working-directory: ros2_example_bazel_installed | |
- name: Test Bazel workspace (ros2_example_installed) | |
run: bazel test //... @ros2//... | |
working-directory: ros2_example_bazel_installed | |
# Use separate save action with explicit `if: always()` to always save | |
# cache, given that Bazel only caches artifacts related to successful | |
# build / tests. | |
- uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: ~/.cache/bazel_ci | |
key: bazel_ci-${{ github.ref }}-${{ github.run_number }}-${{ github.run_attempt }} |