Skip to content

Commit ea4f1ca

Browse files
authored
Merge pull request #7 from LecrisUT/doc/rpminspect
doc: rpminspect
2 parents 497c77b + 2a88934 commit ea4f1ca

File tree

3 files changed

+142
-14
lines changed

3 files changed

+142
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You can alter the inputs of this plan through environment variables.
2121
## Plans available
2222
2323
- Plans equivalent with jobs run on `bohdi`
24-
- [ ] `/rpminspect`
24+
- [`/plans/rpminspect`](plans/rpminspect)
2525
- [ ] `/rpmdeplint`
2626
- [ ] `/installability`
2727
- Other plans

plans/rpminspect/README.md

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# Rpminspect
2+
3+
<!-- SPHINX-START -->
4+
5+
Run [rpminspect] on the current Copr project or Koji build
6+
7+
## Synopsis
8+
9+
```yaml
10+
plans:
11+
import:
12+
url: https://github.com/packit/tmt-plans
13+
ref: main
14+
name: /plans/rpminspect
15+
```
16+
17+
## Description
18+
19+
This plan simply runs the command
20+
21+
```console
22+
$ rpminspect [previous_build] [koji_build/copr_build]
23+
```
24+
25+
where `koji_build` is the build specified by `RPMINSPECT_KOJI_BUILD`. If this option is not provided, it is assumed
26+
that the plan is running against a `copr_build`, and the build artifacts are retrieved automatically from testing-farm.
27+
28+
`previous_build` is automatically determined from running
29+
30+
```console
31+
$ koji list-tagged
32+
```
33+
34+
:::note
35+
36+
Some functionalities like automatically determining `previous_build` are only available for Fedora packages.
37+
38+
:::
39+
40+
## Options
41+
42+
`RPMINSPECT_KOJI_BUILD`
43+
44+
: :::note
45+
46+
Not yet implemented
47+
48+
:::
49+
50+
Run `rpminspect` on the specified Koji build instead of the expected Copr project
51+
52+
`RPMINSPECT_TESTS`
53+
54+
: Run only the specified inspections. This option has precedence over `RPMINSPECT_EXCLUDE`.
55+
56+
See `rpminspect -l` for a list of available tests.
57+
58+
`RPMINSPECT_EXCLUDE` \[Default: `metadata`\]
59+
60+
: Exclude the specified inspections. This option has no effect if `RPMINSPECT_TESTS` is specified.
61+
62+
See `rpminspect -l` for a list of available tests.
63+
64+
`RPMINPSECT_ARCHES`
65+
66+
: Run inspection only on the specified architecture packages
67+
68+
::: note
69+
70+
Keep in mind the architectures available in the testing-farm runner that runs this job.
71+
72+
Also note that `src`, and `noarch` are also considered "architectures" in this context.
73+
74+
:::
75+
76+
## Examples
77+
78+
- Inspect the upstream packit projects
79+
```yaml
80+
plans:
81+
import:
82+
url: https://github.com/packit/tmt-plans
83+
ref: main
84+
name: /plans/rpminspect
85+
```
86+
- Filter `disttag` inspection
87+
```yaml
88+
plans:
89+
import:
90+
url: https://github.com/packit/tmt-plans
91+
ref: main
92+
name: /plans/rpminspect
93+
environment:
94+
RPMINSPECT_EXCLUDE: disttag
95+
```
96+
- Inspect downstream koji builds
97+
```yaml
98+
TBD
99+
```
100+
101+
## See Also
102+
103+
- Downstream Fedora-CI: [docker-runner][fedora-ci-docker], [tmt-plan][fedora-ci-tmt]
104+
- [rpminspect][rpminspect-doc]
105+
106+
<!-- SPHINX-END -->
107+
108+
[fedora-ci-docker]: https://github.com/fedora-ci/rpminspect-runner
109+
[fedora-ci-tmt]: https://github.com/fedora-ci/rpminspect-pipeline
110+
[rpminspect]: https://github.com/rpminspect/rpminspect
111+
[rpminspect-doc]: https://rpminspect.readthedocs.io

tests/rpminspect/rpminspect.sh

+30-13
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@ rlJournalStart
2525
rlRun -s "/usr/bin/koji list-tagged --latest --inherit --quiet f${VERSION_ID} ${PACKIT_PACKAGE_NAME}" 0 "Get latest koji build"
2626
rlRun "latest_build=\$(cat $rlRun_LOG | sed 's/\s.*//')" 0 "Resolve latest_build variable"
2727
if [[ -n "$latest_build" ]]; then
28-
# If the package is already uploaded downstream
28+
## If the package is already uploaded downstream
29+
# Default and required options
30+
args="-v -c ${RPMINSPECT_CONFIG:-/usr/share/rpminspect/fedora.yaml}"
31+
# Fetch and write to ./inspect_builds
32+
args="$args -f -w ./inspect_builds"
33+
# Specify the architectures
2934
# TODO: Should have a better way to get the current arch to cover emulated and other cases
30-
rlRun "/usr/bin/rpminspect -v -c ${RPMINSPECT_CONFIG:-/usr/share/rpminspect/fedora.yaml} -f -w ./inspect_builds --arches=src,noarch,$(arch) $latest_build" 0 "Downloading latest koji builds"
35+
args="$args --arches=src,noarch,$(arch)"
36+
args="$args $latest_build"
37+
rlRun "/usr/bin/rpminspect $args" 0 "Downloading latest koji builds"
3138
fi
3239
else
3340
rlFail "Not implemented for tags other than fedora"
@@ -42,18 +49,28 @@ rlJournalStart
4249
done
4350
rlRun "tree ./inspect_builds"
4451

45-
# Do actual rpminspect
46-
args=""
47-
args="$args -c ${RPMINSPECT_CONFIG:-/usr/share/rpminspect/fedora.yaml}"
48-
args="$args --output=${TMT_TEST_DATA}/result.json --format=json"
49-
args="$args --verbose"
50-
# TODO: Only exclude if running with copr
51-
args="$args --exclude=metadata"
52-
args="$args ${ARCHES:+--arches=$ARCHES}"
53-
args="$args ${RPMINSPECT_TESTS:+--tests=$RPMINSPECT}"
54-
if [[ -n "$latest_build" ]]; then
55-
args="$args ./inspect_builds/$latest_build"
52+
## Do actual rpminspect
53+
# Default and required options
54+
args="-v -c ${RPMINSPECT_CONFIG:-/usr/share/rpminspect/fedora.yaml}"
55+
# Output the data to json so that it can be displayed
56+
args="$args --output=$TMT_TEST_DATA/result.json --format=json"
57+
# Specify the test to run
58+
if [[ -n "$RPMINSPECT_TESTS" ]]; then
59+
# Run only specified tests. Takes precedence over --exclude
60+
args="$args --tests=$RPMINSPECT_TESTS"
61+
elif [[ -n "$RPMINSPECT_EXCLUDE" ]]; then
62+
# Exclude test lists given. Only run if there is no RPMINSPECT_TESTS
63+
args="$args --exclude=${RPMINSPECT_EXCLUDE:-metadata}"
64+
else
65+
# TODO: Only exclude metadata if running with copr
66+
# https://tmt.readthedocs.io/en/stable/spec/context.html#initiator
67+
args="$args --exclude=metadata"
5668
fi
69+
# Run rpminspect for the specified architectures
70+
[[ -n "$RPMINPSECT_ARCHES" ]] && args="$args --arches=$RPMINPSECT_ARCHES"
71+
# If we have a previous build to compare with, use that as before_build
72+
[[ -n "$latest_build" ]] && args="$args ./inspect_builds/$latest_build"
73+
# The remaining part is treated as the after_build/the build to be inspected
5774
args="$args ./inspect_builds/$PACKIT_PACKAGE_NVR"
5875
rlRun "/usr/bin/rpminspect $args" 0 "Run rpminspect"
5976
rlRun "cp $TMT_PLAN_DATA/viewer.html $TMT_TEST_DATA/viewer.html"

0 commit comments

Comments
 (0)