Repository navigation
183 lines (174 loc) · 4.93 KB
/
Copy pathtest.yml
File metadata and controls
183 lines (174 loc) · 4.93 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
name: Test actions
on:
push:
pull_request_target:
env:
COPR_PROJECT: action-copr-${{ github.run_number }}
COPR_ACCOUNT: '@sssd'
jobs:
srpm:
runs-on: ubuntu-latest
outputs:
srpm: ${{ steps.srpm.outputs.file }}
steps:
- name: Create mock project tarball
run: |
echo "#!/bin/bash" > test.sh
echo "echo I am here." >> test.sh
tar -cvzf action-copr-1.tar.gz --transform "s,^,action-copr-1/," *
- name: Create spec file
shell: bash
run: |
cat <<EOF > test.spec
Name: action-copr
Version: 1
Release: 1%{?dist}
Summary: Test action-copr
URL: https://github.com/SSSD/action-copr
License: GPLv3+
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
%description
Test action-copr.
%prep
%setup -q
%install
mkdir -p %{buildroot}/%{_bindir}
mv test.sh %{buildroot}/%{_bindir}/
chmod a+x %{buildroot}/%{_bindir}/test.sh
%files
%{_bindir}/test.sh
EOF
- name: Build source rpm
id: srpm
uses: SSSD/action-build-srpm@master
with:
tarball: action-copr-1.tar.gz
specfile: test.spec
- name: Upload source rpm as an artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.srpm.outputs.file }}
path: ${{ steps.srpm.outputs.path }}
chroots:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
list: ${{ steps.result.outputs.list }}
json: ${{ steps.result.outputs.json }}
steps:
- uses: actions/checkout@v2
- name: Init copr
uses: ./init
with:
token: ${{ secrets.COPR_SECRETS }}
- name: Get chroots
id: result
uses: ./filter-chroots
with:
filter: "fedora-[0-9]+-x86_64"
create:
runs-on: ubuntu-latest
needs: [srpm, chroots]
permissions:
contents: read
steps:
- uses: actions/checkout@v2
- name: Init copr
id: init
uses: ./init
with:
token: ${{ secrets.COPR_SECRETS }}
- name: Create copr project
uses: ./create-project
with:
coprcfg: ${{ steps.init.outputs.coprcfg }}
chroots: ${{ needs.chroots.outputs.list }}
project: ${{ env.COPR_PROJECT }}
account: ${{ env.COPR_ACCOUNT }}
delete-after-days: 1
fedora-review: off
- name: Test that project was created
env:
COPRCFG: ${{ steps.init.outputs.coprcfg }}
run: |
if copr-cli --config "$COPRCFG" list "$COPR_ACCOUNT" | grep "$COPR_PROJECT" &> /dev/null; then
echo "Project exist."
exit 0
else
echo "Project does not exist."
exit 1
fi
- name: Cancel pending builds
uses: ./cancel-builds
with:
coprcfg: ${{ steps.init.outputs.coprcfg }}
project: ${{ env.COPR_PROJECT }}
account: ${{ env.COPR_ACCOUNT }}
- name: Test that there are no pending builds
env:
COPRCFG: ${{ steps.init.outputs.coprcfg }}
run: |
if copr-cli --config "$COPRCFG" list-builds --output-format text-row "$COPR_ACCOUNT/$COPR_PROJECT" | grep "running\|pending"; then
echo "Pending builds exists."
exit 1
else
echo "All builds were cancelled."
exit 0
fi
build:
runs-on: ubuntu-latest
needs: [create, chroots, srpm]
strategy:
matrix:
chroot: ${{ fromJson(needs.chroots.outputs.json) }}
fail-fast: false
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: ${{ needs.srpm.outputs.srpm }}
path: .
- name: Init copr
id: init
uses: ./init
with:
token: ${{ secrets.COPR_SECRETS }}
- name: Build srpm in copr for ${{ matrix.chroot }}
uses: ./submit-build
with:
coprcfg: ${{ steps.init.outputs.coprcfg }}
srpm: ${{ needs.srpm.outputs.srpm }}
chroots: ${{ matrix.chroot }}
project: ${{ env.COPR_PROJECT }}
account: ${{ env.COPR_ACCOUNT }}
delete:
runs-on: ubuntu-latest
needs: [build]
if: always()
permissions:
contents: read
steps:
- uses: actions/checkout@v2
- name: Init copr
id: init
uses: ./init
with:
token: ${{ secrets.COPR_SECRETS }}
- name: Delete project
uses: ./delete-project
with:
coprcfg: ${{ steps.init.outputs.coprcfg }}
project: ${{ env.COPR_PROJECT }}
account: ${{ env.COPR_ACCOUNT }}
- name: Test that project was deleted
env:
COPRCFG: ${{ steps.init.outputs.coprcfg }}
run: |
if copr-cli --config "$COPRCFG" list "$COPR_ACCOUNT" | grep "$COPR_PROJECT" &> /dev/null; then
echo "Project exist."
exit 1
else
echo "Project does not exist."
exit 0
fi