forked from lf-lang/lingua-franca
-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (113 loc) · 6.2 KB
/
check-diff.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Check diff from master
on:
workflow_call:
outputs:
run_c:
description: 'Return true if C tests should be run'
value: ${{ jobs.check.outputs.run_c == 'true' && jobs.check.outputs.skip != 'true' }}
run_cpp:
description: 'Return true if C++ tests should be run'
value: ${{ jobs.check.outputs.run_cpp == 'true' && jobs.check.outputs.skip != 'true' }}
run_py:
description: 'Return true if Python tests should be run'
value: ${{ jobs.check.outputs.run_py == 'true' && jobs.check.outputs.skip != 'true' }}
run_rs:
description: 'Return true if Rust tests should be run'
value: ${{ jobs.check.outputs.run_rs == 'true' && jobs.check.outputs.skip != 'true' }}
run_ts:
description: 'Return true if TypeScript tests should be run'
value: ${{ jobs.check.outputs.run_ts == 'true' && jobs.check.outputs.skip != 'true' }}
run_tracing:
description: 'Return true if tracing tests should be run'
value: ${{ jobs.check.outputs.run_tracing == 'true' && jobs.check.outputs.skip != 'true' }}
run_build:
description: 'Return true if the build should be run'
value: ${{ jobs.check.outputs.skip != 'true' }}
run_misc:
description: 'Return true if the build should be run'
value: ${{ jobs.check.outputs.run_misc == 'true' && jobs.check.outputs.skip != 'true' }}
jobs:
check:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.should-skip.outputs.skip == 'true' }}
run_c: ${{ steps.do.outputs.changed_c == 1 || !github.event.pull_request.draft }}
run_cpp: ${{ steps.do.outputs.changed_cpp == 1 || !github.event.pull_request.draft }}
run_misc: ${{ steps.do.outputs.changed_any == 1 || !github.event.pull_request.draft }}
run_py: ${{ steps.do.outputs.changed_py == 1 || !github.event.pull_request.draft }}
run_rs: ${{ steps.do.outputs.changed_rs == 1 || !github.event.pull_request.draft }}
run_ts: ${{ steps.do.outputs.changed_ts == 1|| !github.event.pull_request.draft }}
run_tracing: ${{ steps.do.outputs.changed_tracing == 1 || !github.event.pull_request.draft }}
steps:
- name: Check out lingua-franca repository
uses: actions/checkout@v3
with:
repository: lf-lang/lingua-franca
submodules: true
fetch-depth: 0
- name: Check for redundant runs
id: duplicate
uses: fkirc/[email protected]
- id: do
name: Check which targets have changes
run: |
./check-diff.sh master "lflang/generator/c\|resources/lib/c\|resources/lib/platform\|test/C" c
./check-diff.sh master "lflang/generator/cpp\|resources/lib/cpp\|test/Cpp" cpp
./check-diff.sh master "lflang/generator/python\|resources/lib/py\|test/Python" py
./check-diff.sh master "lflang/generator/rust\|resources/lib/rs\|test/Rust" rs
./check-diff.sh master "lflang/generator/ts\|resources/lib/ts\|test/TypeScript" ts
./check-diff.sh master "util/tracing" tracing
./check-diff.sh master ".*" any
shell: bash
working-directory: .github/scripts
- id: summarize
name: "Create summary"
run: |
echo '## Summary' > $GITHUB_STEP_SUMMARY
- id: should-skip
name: "Determine whether to skip checks"
run: |
echo ${{ github.ref_name }}
if echo ${{ github.ref_name }} | grep 'gh-readonly-queue'; then
echo "Don't skip, because this is a merge queue commit."
echo "skip=false" >> $GITHUB_OUTPUT
else
echo "skip=${{ steps.duplicate.outputs.should_skip == 'true' && github.event.action != 'ready_for_review' }}" >> $GITHUB_OUTPUT
fi
shell: bash
- id: skip-redundant
name: "Report on skipping checks (prior run found)"
run: |
echo ":tada: A successful prior run has been found:" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.duplicate.outputs.skipped_by }}" >> $GITHUB_STEP_SUMMARY
echo ":heavy_check_mark: Skipping all tests." >> $GITHUB_STEP_SUMMARY
if: ${{ steps.should-skip.outputs.skip == 'true' }}
- id: skip-ignore
name: "Report skipping checks due to inconsequential changes"
run: |
echo ":octopus: The detected changes did not affect any code." >> $GITHUB_STEP_SUMMARY
echo ":heavy_check_mark: Skipping tests. Only building." >> $GITHUB_STEP_SUMMARY
if: ${{ steps.should-skip.outputs.skip != 'true' && steps.do.outputs.changed_any == 0 }}
- id: run-some
name: "Report on running checks (no prior run found)"
run: |
echo ":octopus: No (complete) successful prior run has been found." >> $GITHUB_STEP_SUMMARY
if: ${{ steps.should-skip.outputs.skip != 'true' && steps.do.outputs.changed_any != 0}}
- id: run-ready-mode
name: 'Report on full test run'
run: |
echo ":hourglass: Performing all tests." >> $GITHUB_STEP_SUMMARY
if: ${{ steps.should-skip.outputs.skip != 'true' && steps.do.outputs.changed_any != 0 && !github.event.pull_request.draft}}
- id: run-draft-mode
name: 'Report on partial test run'
run: |
echo ":hourglass: Performing tests potentially affected by detected changes." >> $GITHUB_STEP_SUMMARY
echo '| | running |' >> $GITHUB_STEP_SUMMARY
echo '|---------|-------------------------------------------|' >> $GITHUB_STEP_SUMMARY
echo '| c | `${{ steps.do.outputs.changed_c == 1 }}` |' >> $GITHUB_STEP_SUMMARY
echo '| cpp | `${{ steps.do.outputs.changed_cpp == 1 }}` |' >> $GITHUB_STEP_SUMMARY
echo '| py | `${{ steps.do.outputs.changed_py == 1 }}` |' >> $GITHUB_STEP_SUMMARY
echo '| rs | `${{ steps.do.outputs.changed_rs == 1 }}` |' >> $GITHUB_STEP_SUMMARY
echo '| ts | `${{ steps.do.outputs.changed_ts == 1 }}` |' >> $GITHUB_STEP_SUMMARY
echo '| tracing | `${{ steps.do.outputs.changed_tracing == 1 }}` |' >> $GITHUB_STEP_SUMMARY
if: ${{ steps.should-skip.outputs.skip != 'true' && steps.do.outputs.changed_any != 0 && github.event.pull_request.draft}}