-
Notifications
You must be signed in to change notification settings - Fork 3
149 lines (134 loc) · 4.42 KB
/
pkgcheck.yaml
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
#
# @author: Ryan Tsien
# @email: i@bitbili.net
#
name: pkgcheck
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '.github/**'
- '.gitignore'
- 'README.md'
pull_request:
branches:
- main
paths-ignore:
- '.github/**'
- '.gitignore'
- 'README.md'
types: [opened, reopened, synchronize]
schedule:
- cron: 36 1 * * *
permissions:
contents: read
pull-requests: read
issues: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
PKGCHECK_REPORT_ISSUE_NUMBER: 15
jobs:
scan:
name: scan the whole repo
runs-on: ubuntu-latest
container:
image: ghcr.io/bekcpear/gentoo-env:latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
path: _ryans
- name: prepare the ::gentoo repo
uses: actions/checkout@v4
with:
repository: 'gentoo-mirror/gentoo'
fetch-depth: 1
path: repos/gentoo
- name: setup repos.conf
shell: bash
run: |
cp _ryans/.github/misc/repos.conf /etc/portage/repos.conf/gentoo.conf
sed -Ei "s:@@GITHUB_WORKSPACE@@:${GITHUB_WORKSPACE}:" /etc/portage/repos.conf/gentoo.conf
cat /etc/portage/repos.conf/gentoo.conf
link=$(readlink /etc/portage/make.profile)
link="${GITHUB_WORKSPACE%/}/repos/gentoo${link#*/repos/gentoo}"
ln -sf ${link} /etc/portage/make.profile
ls -l /etc/portage/make.profile
- name: update pkgcheck
shell: bash
run: |
emerge -nvtj --getbinpkg \
--autounmask=y \
--autounmask-license=y \
--autounmask-write=y \
--autounmask-continue=y \
pkgcheck
- name: prepare this repo with the triggered branch
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
fetch-depth: 1
path: repos/ryans
- name: do scan
shell: bash
id: scan
run: |
set -o pipefail
set +e
datetime="$(date -u '+%Y-%m-%d %H:%M:%S %Z')"
_do() {
set -- "$@"
echo -e "\x1b[1;32m>>>\x1b[0m" "$@" >&2
"$@"
}
# modify files of ::gentoo profiles which cannot be overridden by overlay
./_ryans/.github/scripts/modify-profiles.sh _ryans/.github/gentoo repos/gentoo
# echo and generate version file of pkgcheck
_do pkgcheck --version | tee pkgcheck.version
# push to the right directory
_do pushd repos/ryans || exit 1
# do scan
_do pkgcheck scan --exit error -R FormatReporter \
--format '{level},{name},{category},{package},{eclass},{version},{desc}' \
| _do tee "${GITHUB_WORKSPACE}/report.txt"
pkgcheck_ret="$?"
# pop back to the work dir
popd
# generate the report markdown content
_do ./_ryans/.github/scripts/pkgcheckResult2Markdown.sh \
"${GITHUB_WORKSPACE}/report.txt" \
"/var/tmp/report.md" \
"$(git -C ./repos/gentoo rev-list -n1 HEAD)" \
"$datetime" \
"$(cat pkgcheck.version)" \
"https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}"
# tell the next step that the report file is ready
if [[ -n "/var/tmp/report.md" ]]; then
echo "has_report=1" >>$GITHUB_OUTPUT
fi
if [[ $pkgcheck_ret != 0 ]]; then
echo "error!"
if [[ ${{github.event_name}} != "pull_request" ]]; then
echo "please check https://github.com/${{github.repository}}/issues/${PKGCHECK_REPORT_ISSUE_NUMBER}"
fi
exit $pkgcheck_ret
fi
echo "done."
- name: update result issue
if: ${{ always() && github.event_name != 'pull_request' && steps.scan.outputs.has_report }}
uses: actions/github-script@v7
with:
script: |
const fs = require("fs").promises;
var cbody = await fs.readFile("/var/tmp/report.md", "utf8");
github.rest.issues.update({
issue_number: process.env.PKGCHECK_REPORT_ISSUE_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: cbody
})
# TODO: post error info into PR if this action is triggered by PR