Repository navigation
191 lines (171 loc) · 7.18 KB
/
Copy pathPipeline.yml
File metadata and controls
191 lines (171 loc) · 7.18 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# The MIT License (MIT)
#
# Copyright © 2026 The pyTooling Authors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
# persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
name: Pipeline
run-name: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
on:
push:
# 'TagReleaseCommit' dispatches this workflow on the tag it created; a tag pushed by the automatic GITHUB_TOKEN
# doesn't trigger a workflow on its own.
workflow_dispatch:
jobs:
Prepare:
uses: pyTooling/Actions/.github/workflows/PrepareJob.yml@r8
Marketplace:
uses: ./.github/workflows/CheckMarketplaceMetadata.yml
DryRun:
name: 🐧 Dry-run with a valid configuration
runs-on: ubuntu-26.04
steps:
- name: ⏬ Checkout repository to use the local action
uses: actions/checkout@v7
- name: 🔄 Synchronize forked repositories
id: synchronize
uses: ./
with:
github-token: ${{ github.token }}
target-organisation: Paebbels
directory: tests/Valid
dry-run: true
- name: 📋 Verify output parameters
uses: ./.github/actions/check-outputs
with:
synchronized: ${{ steps.synchronize.outputs.synchronized }}
created: ${{ steps.synchronize.outputs.created }}
created-tags: ${{ steps.synchronize.outputs.created-tags }}
skipped: ${{ steps.synchronize.outputs.skipped }}
errors: ${{ steps.synchronize.outputs.errors }}
# 1 branch of 'ghdl' + 1 branch of 'progit2' + 2 branches of 'itertree'
expected-synchronized: 4
# 1 commented out organisation + 1 commented out repository
# Dry-run reads no repository, so no branch is created.
expected-created: 0
# Dry-run reads no repository, so no tag is created.
expected-created-tags: 0
expected-skipped: 2
expected-errors: 0
ErrorHandling:
name: 🐧 Error handling with an invalid configuration
runs-on: ubuntu-26.04
steps:
- name: ⏬ Checkout repository to use the local action
uses: actions/checkout@v7
- name: 🔄 Synchronize forked repositories
id: synchronize
uses: ./
with:
github-token: ${{ github.token }}
target-organisation: Paebbels
directory: tests/Invalid
dry-run: true
fail-on-error: false
- name: 📋 Verify output parameters
uses: ./.github/actions/check-outputs
with:
synchronized: ${{ steps.synchronize.outputs.synchronized }}
created: ${{ steps.synchronize.outputs.created }}
created-tags: ${{ steps.synchronize.outputs.created-tags }}
skipped: ${{ steps.synchronize.outputs.skipped }}
errors: ${{ steps.synchronize.outputs.errors }}
expected-synchronized: 1
expected-created: 0
expected-created-tags: 0
expected-skipped: 0
# 1 missing 'Missing.repos' + 4 malformed lines in 'ghdl.repos'
expected-errors: 5
FailOnError:
name: 🐧 Counted errors let the action fail
runs-on: ubuntu-26.04
steps:
- name: ⏬ Checkout repository to use the local action
uses: actions/checkout@v7
- name: 🔄 Synchronize forked repositories
id: synchronize
continue-on-error: true
uses: ./
with:
github-token: ${{ github.token }}
target-organisation: Paebbels
directory: tests/Invalid
dry-run: true
- name: 📋 Verify the action failed
shell: bash
env:
OUTCOME: ${{ steps.synchronize.outcome }}
run: |
# 📋 Verify the action failed
set +e
ANSI_LIGHT_RED=$'\x1b[91m'
ANSI_LIGHT_GREEN=$'\x1b[92m'
ANSI_NOCOLOR=$'\x1b[0m'
printf "%s" "Checking the action's outcome ... "
if [[ "${OUTCOME}" == "failure" ]]; then
printf "%s\n" "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR} (failure)"
else
printf "%s\n" "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR} (expected 'failure', got '${OUTCOME}')"
printf "::error title=%s::%s\n" "FailOnError" "The action's outcome is '${OUTCOME}', but 'failure' was expected."
exit 1
fi
# A merge commit on 'main' is a release: tag it with the release pull-request's title and start this pipeline again
# on that tag.
TriggerTaggedRelease:
uses: pyTooling/Actions/.github/workflows/TagReleaseCommit.yml@r8
needs:
- Prepare
- Marketplace
- DryRun
- ErrorHandling
- FailOnError
if: needs.Prepare.outputs.is_release_commit == 'true'
permissions:
contents: write # required to create the tag
actions: write # required to start the tagged pipeline
with:
version: ${{ needs.Prepare.outputs.version }}
auto_tag: ${{ needs.Prepare.outputs.is_release_commit }}
secrets: inherit
# In parallel to the release page: propose the version branch update, so consumers pinning '@v1' can be moved to
# this release by merging one pull-request. The workflow is local for now; once it has proven itself here it can be
# promoted to pyTooling/Actions.
UpdateVersionBranch:
uses: ./.github/workflows/UpdateVersionBranch.yml
needs:
- Prepare
- Marketplace
- DryRun
- ErrorHandling
- FailOnError
if: needs.Prepare.outputs.is_release_tag == 'true'
permissions:
contents: write # required to create a version branch
pull-requests: write # required to open the pull-request
with:
version: ${{ needs.Prepare.outputs.version }}
prefix: 'v'
# The tagged run publishes the release page. Its description is the body of the pull-request that produced the
# tagged merge commit, which 'PublishReleaseNotes' looks up itself.
ReleasePage:
uses: pyTooling/Actions/.github/workflows/PublishReleaseNotes.yml@r8
needs:
- Prepare
- Marketplace
- DryRun
- ErrorHandling
- FailOnError
if: needs.Prepare.outputs.is_release_tag == 'true'
with:
tag: ${{ needs.Prepare.outputs.version }}
secrets: inherit