forked from protocolbuffers/protobuf
-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (56 loc) · 2.5 KB
/
staleness_check.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
name: Staleness tests
on:
schedule:
# Run daily at 10 AM UTC (2 AM PDT)
- cron: 0 10 * * *
workflow_call:
inputs:
safe-checkout:
required: false
description: "The SHA key for the commit we want to run over"
type: string
workflow_dispatch:
permissions: {}
jobs:
test:
strategy:
fail-fast: false
matrix:
branch: [main, 22.x, 23.x, 24.x, 25.x]
os: [{ name: Linux, value: ubuntu-latest}]
name: Test staleness ${{ matrix.os.name }} ${{ github.head_ref && 'PR' || matrix.branch }}
runs-on: ${{ matrix.os.value }}
if: ${{ github.event.repository.full_name == 'protocolbuffers/protobuf' }}
steps:
- name: Checkout ${{ github.head_ref && 'PR' || matrix.branch }}
uses: protocolbuffers/protobuf-ci/checkout@v2
with:
ref: ${{ inputs.safe-checkout || github.head_ref || matrix.branch }}
- name: Mark runs associated with commits
if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' }}
run: echo "COMMIT_TRIGGERED_RUN=1" >> $GITHUB_ENV
- name: Mark runs from the main branch
if: ${{ github.base_ref == 'main' || github.ref == 'refs/heads/main' }}
run: echo "MAIN_RUN=1" >> $GITHUB_ENV
- name: Run all staleness tests
# Run all tests if either of the following is true, otherwise simply run the query to make
# sure it continues to work:
# 1) If this is not a commit-based run it means it's scheduled or manually dispatched. In
# this case we want to make sure there are no stale files.
# 2) Release branches don't work with automated commits (see b/287117570). Until this is
# fixed, we want to run the tests to force manual regeneration when necessary.
#
# In branches where automatic updates work as post-submits, we don't want to run staleness
# tests along with user changes. Any stale files will be automatically fixed in a follow-up
# commit.
uses: protocolbuffers/protobuf-ci/bazel@v2
with:
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
bazel-cache: staleness
bash: >
if [[ -z $COMMIT_TRIGGERED_RUN || -z $MAIN_RUN ]]; then
bazel query 'attr(tags, "staleness_test", //...)' | xargs bazel test $BAZEL_FLAGS ||
echo "Please run ./regenerate_stale_files.sh to regenerate stale files";
else
bazel query 'attr(tags, "staleness_test", //...)';
fi