Plugins test #194
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
# Copyright 2023 Google LLC | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: Plugins test | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- plugins/** | |
push: | |
branches: | |
- main | |
paths: | |
- plugins/** | |
schedule: | |
# GitHub removes infrequently accessed caches. Run once a week to keep the cache from going stale. | |
- cron: '0 0 * * 1' | |
# Default permissions are read only. | |
permissions: read-all | |
jobs: | |
test: | |
name: bazel test (${{ matrix.name }}) | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- name: 'opt' | |
flags: --config=clang -c opt --define=crypto=system | |
- name: 'ASan' | |
flags: --config=clang-asan | |
- name: 'TSan' | |
flags: --config=clang-tsan | |
steps: | |
- uses: actions/checkout@v3 | |
- name: set cache name | |
id: vars | |
working-directory: ./plugins | |
# The cache tag consists of the following parts: | |
# * bazel-cache- prefix | |
# * matrix.name, which separates the cache for opt, tsan, and asan. | |
# * hash of WORKSPACE, .bazelrc, and .bazelversion, which is | |
# purely to differentiate caches for substantial changes in bazel. | |
# * github.sha, which is the commit hash of the commit used to generate | |
# the cache entry. | |
run: echo "CACHE_TAG=bazel-cache-${{ matrix.name }}-${{ hashFiles('WORKSPACE', '.bazelrc', '.bazelversion') }}" >> "$GITHUB_OUTPUT" | |
- name: bazel cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: /tmp/bazel/cache | |
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} | |
restore-keys: | | |
${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} | |
${{ steps.vars.outputs.CACHE_TAG }}- | |
bazel-cache-${{ matrix.name }}- | |
bazel-cache- | |
- name: bazel test | |
shell: bash | |
working-directory: ./plugins | |
run: > | |
bazel test | |
--verbose_failures | |
--test_output=errors | |
--disk_cache /tmp/bazel/cache | |
${{ matrix.flags }} | |
-- //... | |
- name: remove unaccessed files from cache | |
shell: bash | |
run: > | |
find /tmp/bazel/cache | |
-type f | |
-name '*' | |
-amin +300 | |
-exec rm {} \; | |
- name: save bazel cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: /tmp/bazel/cache | |
key: ${{ steps.vars.outputs.CACHE_TAG }}-${{ github.sha }} | |