Skip to content

Commit

Permalink
Update WFA actions to v2.
Browse files Browse the repository at this point in the history
This uses the new action to load the Bazel cache for workflows which use Bazel.
  • Loading branch information
SanjayVas committed May 15, 2023
1 parent dca6527 commit 2f4122d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 35 deletions.
80 changes: 63 additions & 17 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,45 @@ jobs:
name: Build and test
runs-on: ubuntu-20.04
env:
CONTAINER_REGISTRY: "localhost:5001"
IMAGE_REPO_PREFIX: halo
HOST_PLATFORM: //build/platforms:ubuntu_20_04
CLUSTER_LOGS_PATH: cluster-logs
steps:
- name: Check out revision
uses: actions/checkout@v3

- name: Get Bazel cache params
id: get-cache-params
uses: world-federation-of-advertisers/actions/bazel-get-cache-params@v2
with:
cache-version: 1
bazel-options: |-
--compilation_mode=opt
--host_platform=${{ env.HOST_PLATFORM }}
- name: Restore Bazel cache
uses: actions/cache/restore@v3
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
key: ${{ steps.get-cache-params.outputs.cache-key }}
restore-keys: |
${{ steps.get-cache-params.outputs.restore-key }}
- name: Build
run: >
bazelisk build //...
--compilation_mode=opt
--host_platform="$HOST_PLATFORM"
- name: Run tests
id: run-tests
run: >
bazelisk test //...
--compilation_mode=opt
--host_platform="$HOST_PLATFORM"
# Shut down Bazel server to reclaim memory.
- run: bazelisk shutdown

- name: Create cluster
id: create-cluster
run: |
Expand All @@ -42,31 +74,45 @@ jobs:
chmod +x kind-with-registry.sh
./kind-with-registry.sh
- name: Bazel build and test
uses: world-federation-of-advertisers/actions/bazel-build-test@v1
with:
cache-version: 1
workspace-path: .
target-patterns: |
//...
//src/test/kotlin/org/wfanet/measurement/integration/k8s:EmptyClusterCorrectnessTest
build-options: |
--compilation_mode=opt
--host_platform=//build/platforms:ubuntu_20_04
--define=container_registry=${{ env.CONTAINER_REGISTRY }}
--define=image_repo_prefix=${{ env.IMAGE_REPO_PREFIX }}
--define=image_tag=latest
- name: Run correctness test
id: run-correctness-test
env:
CONTAINER_REGISTRY: "localhost:5001"
IMAGE_REPO_PREFIX: halo
run: >
bazelisk test
//src/test/kotlin/org/wfanet/measurement/integration/k8s:EmptyClusterCorrectnessTest
--compilation_mode=opt
--host_platform="$HOST_PLATFORM"
--define=container_registry="$CONTAINER_REGISTRY"
--define=image_repo_prefix="$IMAGE_REPO_PREFIX"
--define=image_tag=latest
- name: Export cluster logs
id: export-cluster-logs
if: failure() && steps.create-cluster.outcome == 'success'
if: failure() && steps.run-correctness-test.outcome == 'failure'
continue-on-error: true
run: |
mkdir -p "$CLUSTER_LOGS_PATH"
kind export logs "$CLUSTER_LOGS_PATH"
- name: Upload cluster logs artifact
if: failure() && steps.export-cluster-logs.outcome == 'success'
uses: actions/upload-artifact@v3
continue-on-error: true
with:
name: cluster-logs
path: ${{ env.CLUSTER_LOGS_PATH }}

- name: Save Bazel cache
if: github.event_name == 'push'
uses: actions/cache/save@v3
continue-on-error: true
with:
path: ${{ steps.get-cache-params.outputs.cache-path }}
key: ${{ steps.get-cache-params.outputs.cache-key }}

- name: Upload Bazel testlogs
continue-on-error: true
uses: world-federation-of-advertisers/actions/bazel-upload-testlogs@v2
if: failure() && (steps.run-tests.outcome == 'failure' || steps.run-correctness-test.outcome == 'failure')
20 changes: 2 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,12 @@ jobs:
lint:
name: Lint changed files
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
steps:
- name: Check out revision
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
java-package: jdk
architecture: x64
distribution: 'zulu'

- name: Set up linters
uses: world-federation-of-advertisers/actions/setup-linters@v1

- name: Lint
uses: world-federation-of-advertisers/actions/lint@v1
- uses: world-federation-of-advertisers/actions/lint@v2
with:
license-type: apache
copyright-holder: The Cross-Media Measurement Authors

0 comments on commit 2f4122d

Please sign in to comment.