Skip to content

Commit ab02fe2

Browse files
Merge pull request #23086 from cevich/lint_in_parallel
Run linting in parallel with building
2 parents d386cd0 + 6c75a10 commit ab02fe2

File tree

4 files changed

+83
-108
lines changed

4 files changed

+83
-108
lines changed

.cirrus.yml

Lines changed: 60 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,48 @@ gcp_credentials: ENCRYPTED[a28959877b2c9c36f151781b0a05407218cda646c7d047fc556e4
7979
aws_credentials: ENCRYPTED[4ca070bffe28eb9b27d63c568b52970dd46f119c3a83b8e443241e895dbf1737580b4d84eed27a311a2b74287ef9f79f]
8080

8181

82+
validate-source_task:
83+
name: "Validate source code changes"
84+
alias: validate-source
85+
# This task is primarily intended to catch human-errors early on, in a
86+
# PR context. Skip running it everywhere else.
87+
only_if: &is_pr "$CIRRUS_PR != ''"
88+
gce_instance:
89+
image_project: libpod-218412
90+
zone: "us-central1-a"
91+
# golangci-lint is a very, very hungry beast.
92+
cpu: 8
93+
memory: "16Gb"
94+
# Required to be 200gig, do not modify - has i/o performance impact
95+
# according to gcloud CLI tool warning messages.
96+
disk: 200
97+
image_name: "${FEDORA_CACHE_IMAGE_NAME}" # from stdenvars
98+
env:
99+
TEST_FLAVOR: validate-source
100+
# NOTE: The default way Cirrus-CI clones is *NOT* compatible with
101+
# environment expectations in contrib/cirrus/lib.sh. Specifically
102+
# the 'origin' remote must be defined, and all remote branches/tags
103+
# must be available for reference from CI scripts.
104+
clone_script: &full_clone |
105+
set -exo pipefail
106+
cd /
107+
rm -rf $CIRRUS_WORKING_DIR
108+
mkdir -p $CIRRUS_WORKING_DIR
109+
git clone --recursive --branch=$DEST_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
110+
cd $CIRRUS_WORKING_DIR
111+
git remote update origin
112+
if [[ -n "$CIRRUS_PR" ]]; then # running for a PR
113+
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
114+
git checkout pull/$CIRRUS_PR
115+
else
116+
git reset --hard $CIRRUS_CHANGE_IN_REPO
117+
fi
118+
# Standard setup stage call, used by nearly every task in CI.
119+
setup_script: &setup '$GOSRC/$SCRIPT_BASE/setup_environment.sh'
120+
# Standard main execution stage call, used by nearly every task in CI.
121+
main_script: &main '/usr/bin/time --verbose --output="$STATS_LOGFILE" $GOSRC/$SCRIPT_BASE/runner.sh'
122+
123+
82124
# N/B: This matrix of build tasks are critical to CI, along with the following
83125
# aarch64 task. They build binaries for all CI platforms, and versions. On
84126
# success, the contents of the repository are preserved as an artifact for
@@ -120,33 +162,15 @@ build_task:
120162
CI_DESIRED_NETWORK: netavark
121163
env:
122164
TEST_FLAVOR: build
123-
# NOTE: The default way Cirrus-CI clones is *NOT* compatible with
124-
# environment expectations in contrib/cirrus/lib.sh. Specifically
125-
# the 'origin' remote must be defined, and all remote branches/tags
126-
# must be available for reference from CI scripts.
127-
clone_script: &full_clone |
128-
set -exo pipefail
129-
cd /
130-
rm -rf $CIRRUS_WORKING_DIR
131-
mkdir -p $CIRRUS_WORKING_DIR
132-
git clone --recursive --branch=$DEST_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR
133-
cd $CIRRUS_WORKING_DIR
134-
git remote update origin
135-
if [[ -n "$CIRRUS_PR" ]]; then # running for a PR
136-
git fetch origin pull/$CIRRUS_PR/head:pull/$CIRRUS_PR
137-
git checkout pull/$CIRRUS_PR
138-
else
139-
git reset --hard $CIRRUS_CHANGE_IN_REPO
140-
fi
165+
clone_script: *full_clone
141166
# Attempt to prevent flakes by confirming basic environment expectations,
142167
# network service connectivity and essential container image availability.
168+
# TODO: Rename to "ci-sanity" and move into task that runs in parallel to build
143169
prebuild_script: &prebuild $SCRIPT_BASE/prebuild.sh
144-
# Standard setup stage call, used by nearly every task in CI.
145-
setup_script: &setup '$GOSRC/$SCRIPT_BASE/setup_environment.sh'
170+
setup_script: *setup
146171
# Attempt to prevent flakes by confirming automation environment and
147172
# all required external/3rd-party services are available and functional.
148-
# Standard main execution stage call, used by nearly every task in CI.
149-
main_script: &main '/usr/bin/time --verbose --output="$STATS_LOGFILE" $GOSRC/$SCRIPT_BASE/runner.sh'
173+
main_script: *main
150174
# Attempt to catch code-quality and vendoring problems early.
151175
postbuild_script: &postbuild $SCRIPT_BASE/postbuild.sh
152176
# Cirrus-CI is very slow uploading one file at time, and the repo contains
@@ -162,48 +186,6 @@ build_task:
162186
type: text/plain
163187

164188

165-
# Confirm the result of building on at least one platform appears sane.
166-
# This confirms the binaries can be executed, checks --help vs docs, and
167-
# other essential post-build validation checks.
168-
validate_task:
169-
name: "Validate ${DISTRO_NV} Build"
170-
alias: validate
171-
# This task is primarily intended to catch human-errors early on, in a
172-
# PR. Skip it for branch-push, branch-create, and tag-push to improve
173-
# automation reliability/speed in those contexts. Any missed errors due
174-
# to nonsequential PR merging practices, will be caught on a future PR,
175-
# build or test task failures.
176-
# Docs: ./contrib/cirrus/CIModes.md
177-
only_if: &is_pr "$CIRRUS_PR != ''"
178-
depends_on:
179-
- build
180-
# golangci-lint is a very, very hungry beast.
181-
gce_instance: &bigvm
182-
<<: *standardvm
183-
cpu: 8
184-
memory: "16Gb"
185-
matrix:
186-
- env:
187-
<<: *stdenvars
188-
VM_IMAGE_NAME: ${FEDORA_CACHE_IMAGE_NAME}
189-
DISTRO_NV: ${FEDORA_NAME}
190-
- env:
191-
<<: *stdenvars
192-
VM_IMAGE_NAME: ${RAWHIDE_CACHE_IMAGE_NAME}
193-
DISTRO_NV: ${RAWHIDE_NAME}
194-
env:
195-
TEST_FLAVOR: validate
196-
# N/B: This script depends on ${DISTRO_NV} being defined for the task.
197-
clone_script: &get_gosrc |
198-
cd /tmp
199-
echo "$ARTCURL/Build%20for%20${DISTRO_NV}/repo/repo.tbz"
200-
time $ARTCURL/Build%20for%20${DISTRO_NV}/repo/repo.tbz
201-
time tar xjf /tmp/repo.tbz -C $GOSRC
202-
setup_script: *setup
203-
main_script: *main
204-
always: *runner_stats
205-
206-
207189
build_aarch64_task:
208190
alias: 'build_aarch64'
209191
name: 'Build for $DISTRO_NV'
@@ -219,6 +201,7 @@ build_aarch64_task:
219201
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
220202
TEST_FLAVOR: build
221203
clone_script: *full_clone
204+
# TODO: Rename to "ci-sanity" and move into task that runs in parallel to build
222205
prebuild_script: *prebuild
223206
setup_script: *setup
224207
postbuild_script: *postbuild
@@ -233,37 +216,6 @@ build_aarch64_task:
233216
always: *runner_stats
234217

235218

236-
# Confirm the result of building on at least one platform appears sane.
237-
# This confirms the binaries can be executed, checks --help vs docs, and
238-
# other essential post-build validation checks.
239-
validate_aarch64_task:
240-
name: "Validate $DISTRO_NV Build"
241-
alias: validate_aarch64
242-
# This task is primarily intended to catch human-errors early on, in a
243-
# PR. Skip it for branch-push, branch-create, and tag-push to improve
244-
# automation reliability/speed in those contexts. Any missed errors due
245-
# to nonsequential PR merging practices, will be caught on a future PR,
246-
# build or test task failures.
247-
# Docs: ./contrib/cirrus/CIModes.md
248-
only_if: *is_pr
249-
depends_on:
250-
- build_aarch64
251-
ec2_instance: *standard_build_ec2_aarch64
252-
env:
253-
<<: *stdenvars_aarch64
254-
TEST_FLAVOR: validate
255-
DISTRO_NV: ${FEDORA_AARCH64_NAME}
256-
# N/B: This script depends on ${DISTRO_NV} being defined for the task.
257-
clone_script: &get_gosrc_aarch64 |
258-
cd /tmp
259-
echo "$ARTCURL/build_aarch64/repo/repo.tbz"
260-
time $ARTCURL/build_aarch64/repo/repo.tbz
261-
time tar xjf /tmp/repo.tbz -C $GOSRC
262-
setup_script: *setup
263-
main_script: *main
264-
always: *runner_stats
265-
266-
267219
# There are several other important variations of podman which
268220
# must always build successfully. Most of them are handled in
269221
# this task, though a few need dedicated tasks which follow.
@@ -393,10 +345,9 @@ build_success_task:
393345
name: "Total Build Success"
394346
alias: build_success
395347
depends_on:
348+
- validate-source
396349
- build
397-
- validate
398350
- build_aarch64
399-
- validate_aarch64
400351
- alt_build
401352
- osx_alt_build
402353
- freebsd_alt_build
@@ -430,7 +381,12 @@ bindings_task:
430381
env:
431382
<<: *stdenvars
432383
TEST_FLAVOR: bindings
433-
clone_script: *get_gosrc
384+
# N/B: This script depends on ${DISTRO_NV} being defined for the task.
385+
clone_script: &get_gosrc |
386+
cd /tmp
387+
echo "$ARTCURL/Build%20for%20${DISTRO_NV}/repo/repo.tbz"
388+
time $ARTCURL/Build%20for%20${DISTRO_NV}/repo/repo.tbz
389+
time tar xjf /tmp/repo.tbz -C $GOSRC
434390
setup_script: *setup
435391
main_script: *main
436392
always: &logs_artifacts
@@ -781,7 +737,12 @@ podman_machine_aarch64_task:
781737
PRIV_NAME: "rootless" # intended use-case
782738
DISTRO_NV: "${FEDORA_AARCH64_NAME}"
783739
VM_IMAGE_NAME: "${FEDORA_AARCH64_AMI}"
784-
clone_script: *get_gosrc_aarch64
740+
# N/B: This script depends on ${DISTRO_NV} being defined for the task.
741+
clone_script: &get_gosrc_aarch64 |
742+
cd /tmp
743+
echo "$ARTCURL/build_aarch64/repo/repo.tbz"
744+
time $ARTCURL/build_aarch64/repo/repo.tbz
745+
time tar xjf /tmp/repo.tbz -C $GOSRC
785746
setup_script: *setup
786747
main_script: *main
787748
always: *int_logs_artifacts

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,16 @@ test/version/version: version/version.go
311311
codespell:
312312
codespell -S bin,vendor,.git,go.sum,.cirrus.yml,"*.fish,RELEASE_NOTES.md,*.xz,*.gz,*.ps1,*.tar,swagger.yaml,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L secon,passt,bu,hastable,te,clos,ans,pullrequest,uint,iff,od,seeked,splitted,marge,erro,hist,ether,specif -w
313313

314-
.PHONY: validate
315-
validate: lint .gitvalidation validate.completions man-page-check swagger-check tests-expect-exit pr-removes-fixed-skips
314+
# Code validation target that **DOES NOT** require building podman binaries
315+
.PHONY: validate-source
316+
validate-source: lint .gitvalidation swagger-check tests-expect-exit pr-removes-fixed-skips
317+
318+
# Code validation target that **DOES** require building podman binaries
319+
.PHONY: validate-binaries
320+
validate-binaries: man-page-check validate.completions
316321

322+
.PHONY: validate
323+
validate: validate-source validate-binaries
317324

318325
# The image used below is generated manually from contrib/validatepr/Containerfile in this podman repo. The builds are
319326
# not automated right now. The hope is that eventually the quay.io/libpod/fedora_podman is multiarch and can replace this
@@ -601,7 +608,7 @@ docker-docs: docs
601608

602609
.PHONY: validate.completions
603610
validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target
604-
validate.completions:
611+
validate.completions: completions
605612
# Check if the files can be loaded by the shell
606613
. completions/bash/podman
607614
if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi

contrib/cirrus/runner.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ source $(dirname $0)/lib.sh
2121

2222
showrun echo "starting"
2323

24-
function _run_validate() {
25-
showrun make validate
24+
function _run_validate-source() {
25+
showrun make validate-source
2626

2727
# make sure PRs have tests
2828
showrun make tests-included
@@ -207,10 +207,18 @@ eof
207207
}
208208

209209
function _run_build() {
210+
local vb_target
211+
212+
# There's no reason to validate-binaries across multiple linux platforms
213+
# shellcheck disable=SC2154
214+
if [[ "$DISTRO_NV" =~ $FEDORA_NAME ]]; then
215+
vb_target=validate-binaries
216+
fi
217+
210218
# Ensure always start from clean-slate with all vendor modules downloaded
211219
showrun make clean
212220
showrun make vendor
213-
showrun make podman-release # includes podman, podman-remote, and docs
221+
showrun make podman-release $vb_target # includes podman, podman-remote, and docs
214222

215223
# Last-minute confirmation that we're testing the desired runtime.
216224
# This Can't Possibly Fail™ in regular CI; only when updating VMs.

contrib/cirrus/setup_environment.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,8 @@ esac
306306
# shellcheck disable=SC2154
307307
showrun echo "about to set up for TEST_FLAVOR [=$TEST_FLAVOR]"
308308
case "$TEST_FLAVOR" in
309-
validate)
310-
# For some reason, this is also needed for validation
311-
showrun make .install.pre-commit .install.gitvalidation
309+
validate-source)
310+
# NOOP
312311
;;
313312
altbuild)
314313
# Defined in .cirrus.yml

0 commit comments

Comments
 (0)