.gitbay/ci.yml

55 lines · 3205 bytes

 1jobs:
 2  # Fast feedback: this finishes in seconds, so it is not held behind the
 3  # suite.
 4  build:
 5    image: localhost/gitbay-ci:3
 6    steps:
 7      - go build ./...
 8      - go vet ./...
 9  # The suite drives real git, ssh, sshd and gpg. Several tests skip
10  # themselves when a tool is absent, so the prerequisites are asserted
11  # first, all of them in one step so one run names everything to install.
12  # A green check that quietly tested less is worse than a red one.
13  # The 20m is under the runner's own 30m limit, so go times out first and
14  # says which test hung instead of the runner killing it blind.
15  test:
16    image: localhost/gitbay-ci:3
17    steps:
18      - missing=""; for t in git git-lfs gpg; do command -v "$t" >/dev/null || missing="$missing $t"; done; test -x /usr/sbin/sshd || missing="$missing sshd"; test -z "$missing" || { echo "runner is missing:$missing"; exit 1; }
19      - go test ./... -count=1 -timeout 20m
20    paths-ignore:
21      - .gitbay/wiki/**
22  # Static analysis through Qlty (.qlty/qlty.toml). Secrets and gofmt fail
23  # the build. The full report, including radarlint-go's Sonar rules, is
24  # printed without failing it. The CLI is pinned, and unpacked with Python
25  # because this image has no xz.
26  quality:
27    image: localhost/gitbay-ci:3
28    steps:
29      - curl -fsSL -o /tmp/qlty.tar.xz https://qlty-releases.s3.amazonaws.com/qlty/v0.661.0/qlty-x86_64-unknown-linux-gnu.tar.xz && python3 -c "import tarfile; tarfile.open('/tmp/qlty.tar.xz').extractall('/tmp', filter='data')"
30      - QLTY_TELEMETRY=off /tmp/qlty-x86_64-unknown-linux-gnu/qlty check --all --no-progress --filter trufflehog,gofmt
31      - QLTY_TELEMETRY=off /tmp/qlty-x86_64-unknown-linux-gnu/qlty check --all --no-progress --no-fail
32    paths-ignore:
33      - .gitbay/wiki/**
34  # Vulnerability scanning, separate from test so a newly published advisory
35  # against unchanged code does not mask a real test failure. It fails the
36  # build on purpose: an advisory that only lands in a report nobody reads is
37  # the state this replaced. @latest matches deploy/audit.sh, so a run scans
38  # against the database as it is today, not as it was at commit time.
39  #
40  # Nightly rather than per-push, because that last sentence is the whole
41  # job: the trigger is the advisory database, not the code. An advisory
42  # published against code nobody touched was invisible until someone
43  # happened to push, while a rebase that changed nothing re-scanned it.
44  # A schedule asks the question on the cadence the answer changes.
45  # `build trigger krz/gitbay vuln` runs it on demand before a release
46  # (#177).
47  vuln:
48    image: localhost/gitbay-ci:3
49    schedule: "0 3 * * *"
50    steps:
51      - go run golang.org/x/vuln/cmd/govulncheck@latest ./...
52      # osv-scanner also reports advisories in dependencies the code does not
53      # call, which govulncheck skips.
54      - curl -fsSL -o /tmp/qlty.tar.xz https://qlty-releases.s3.amazonaws.com/qlty/v0.661.0/qlty-x86_64-unknown-linux-gnu.tar.xz && python3 -c "import tarfile; tarfile.open('/tmp/qlty.tar.xz').extractall('/tmp', filter='data')"
55      - QLTY_TELEMETRY=off /tmp/qlty-x86_64-unknown-linux-gnu/qlty check --all --no-progress --filter osv-scanner