-
Notifications
You must be signed in to change notification settings - Fork 2
118 lines (107 loc) · 4.02 KB
/
main.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
116
117
118
name: main
on:
workflow_dispatch:
inputs:
skip-tests:
description: Skip tests
required: false
default: false
type: boolean
skip-build-app:
description: Skip build-app
required: false
default: false
type: boolean
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled]
issue_comment:
types: [created, edited, deleted]
defaults:
run:
shell: bash --noprofile --norc -x -euo pipefail {0}
jobs:
paths-filter:
name: 'Paths Filter'
uses: ./.github/workflows/paths-filter.yml
labels-filter:
name: 'Labels Filter'
runs-on: ubuntu-latest
outputs:
should-test: ${{ steps.filter.outputs.should-test }}
should-build: ${{ steps.filter.outputs.should-build }}
steps:
- name: 'Filter labels'
id: filter
if: ${{ github.event_name == 'pull_request' && github.event.action == 'labeled' }}
run: |
if [[ "${{ github.event.label.name }}" =~ 'ci: test' ]]; then
echo "should-test=true" >> $GITHUB_OUTPUT
fi
if [[ "${{ github.event.label.name }}" =~ 'ci: build' ]]; then
echo "should-build=true" >> $GITHUB_OUTPUT
fi
comments-filter:
name: 'Comments filter'
runs-on: ubuntu-latest
steps:
- name: 'Filter comments'
if: ${{ github.event_name == 'issue_comment' }}
run: |
if [[ "${{ github.event.comment.body }}" =~ '@ci test this please' ]]; then
gh pr edit "$PR" --add-label 'ci: test'
fi
if [[ "${{ github.event.comment.body }}" =~ '@ci build this please' ]]; then
gh pr edit "$PR" --add-label 'ci: build'
fi
env:
PR: ${{ github.event.pull_request.number }}
tests:
name: 'Tests'
needs: [paths-filter, labels-filter]
if: ${{ !inputs.skip-tests && github.event.pull_request.draft != true && needs.paths-filter.outputs.should-test != 'false' && needs.labels-filter.outputs.should-test == 'true' }}
uses: grigorye/ReusableWorkflows/.github/workflows/tests-generic.yml@v20
secrets: inherit
with:
runs-on: 'macos-12'
unit-tests-scheme: 'TMBuddyTests'
snapshot-tests-scheme: 'TMBuddySnapshots'
ui-snapshot-tests-scheme: 'TMBuddyUITestSnapshots'
build-app:
name: 'App'
needs: [paths-filter, labels-filter]
if: ${{ !inputs.skip-build-app && github.event.pull_request.draft != true && needs.paths-filter.outputs.should-build != 'false' && needs.labels-filter.outputs.should-build == 'true' }}
uses: grigorye/ReusableWorkflows/.github/workflows/build-app-generic.yml@v20
with:
macos-app-scheme: 'TMBuddy'
build-configs: '[\"app-store\", \"developer-id\"]'
secrets: inherit
finalize:
name: 'Finalize Run'
if: always()
needs: [paths-filter, tests, build-app]
runs-on: ubuntu-latest
steps:
- name: 'Flag non-succeeding app builds'
if: always() && needs.paths-filter.outputs.should-build != 'false' && needs.build-app.result != 'success'
uses: actions/github-script@v6
with:
script: |
core.setFailed('Some app build did not succeed.')
- name: 'Flag tests that did not run'
if: always() && needs.paths-filter.outputs.should-test != 'false' && needs.tests.result != 'success'
uses: actions/github-script@v6
with:
script: |
core.setFailed('Some tests did not run.')
- name: 'Flag tests that did fail'
if: always() && needs.paths-filter.outputs.should-test != 'false' && needs.tests.outputs.tests-passed != 'true'
uses: actions/github-script@v6
with:
script: |
core.setFailed('Some tests did fail.')
- name: 'Report success for skipped jobs'
if: always() && needs.paths-filter.outputs.should-test == 'false' && needs.paths-filter.outputs.should-build == 'false'
run: |
echo 'No job to do.'