Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cicd: fix nightly build #2040

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/actions/set-image-expiration/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
duration:
description: 'Duration (in seconds) into the future to expire the image.'
required: false
default: 1209600
default: '1209600'
repo:
description: 'Namespace & repository'
required: true
Expand All @@ -22,10 +22,12 @@ runs:
using: 'composite'
steps:
- id: add-mask
name: Add Mask
shell: sh
run: |
printf '::add-mask::%s\n' "${{ inputs.token }}"
- id: write-script
name: Prepare Request
shell: sh
run: |
jq -n -c --argjson e "$(($(date -u +%s) + ${{ inputs.duration }}))" '{expiration: $e}' > "${RUNNER_TEMP}/expiration.json"
Expand All @@ -43,5 +45,6 @@ runs:
.
chmod +x "${RUNNER_TEMP}/run"
- id: call
name: Execute Request
shell: sh
run: '${RUNNER_TEMP}/run'
30 changes: 21 additions & 9 deletions .github/script/nightly-module.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
#!/bin/sh
set -e
: "${CLAIRCORE_BRANCH:=main}"
: "${GO_VERSION:=1.20}"
test "${#GO_VERSION}" -gt 4 && GO_VERSION=${GO_VERSION%.*}

cd "$(git rev-parse --show-toplevel)"
echo '#' "$(go version)"
go mod edit "-go=${GO_VERSION}"\
"-replace=github.com/quay/claircore=github.com/quay/claircore@${CLAIRCORE_BRANCH}"
git diff
test -d vendor && rm -rf vendor

echo "::group::Edits"
go mod edit \
"-replace=github.com/quay/claircore=github.com/quay/claircore@${CLAIRCORE_BRANCH}"
go mod tidy
go mod vendor
echo "clair_version=$(git describe --tags --always --dirty --match 'v4.*')" >> "$GITHUB_OUTPUT"
go mod download # Shouldn't be needed, but just to be safe...
echo "::endgroup::"

clair_version="$(git describe --tags --always --dirty --match 'v4.*')"
echo "clair_version=${clair_version}" >> "$GITHUB_OUTPUT"

cat <<. >>"$GITHUB_STEP_SUMMARY"
### Changes

- **Go version:** $(go version)
- **Clair version:** ${clair_version}
.
{
echo '```patch'
git diff
echo '```'
} >>"$GITHUB_STEP_SUMMARY"
26 changes: 11 additions & 15 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ on:
branch:
description: 'Claircore branch to reference'
required: false
go_version:
description: 'Go version to be used throughout'
required: false
tag:
description: 'Tag to push resulting image to'
required: false
Expand All @@ -30,7 +27,6 @@ jobs:
# nicer workflow inputs so that the cron trigger works.
run: |
br=$(test -n "${{github.event.inputs.branch}}" && echo "${{github.event.inputs.branch}}" || echo main)
gv=$(test -n "${{github.event.inputs.go_version}}" && echo "${{github.event.inputs.go_version}}" || echo 1.20)
: "${repo:=$GITHUB_REPOSITORY}"
test "${repo%%/*}" = quay && repo="projectquay/${repo##*/}" ||:
cat <<. >>$GITHUB_OUTPUT
Expand All @@ -39,27 +35,27 @@ jobs:
date=$(date -u '+%Y-%m-%d')
tag=$(test -n "${{github.event.inputs.tag}}" && echo "${{github.event.inputs.tag}}" || echo nightly)
claircore_branch=${br}
go_version=${gv}
repo=${repo}
.
# Environment variables
printf 'CLAIRCORE_BRANCH=%s\n' "${br}" >> $GITHUB_ENV
printf 'GO_VERSION=%s\n' "$gv" >> $GITHUB_ENV
printf '%s/.local/go/bin\n' "$HOME" >> $GITHUB_PATH
- uses: docker/setup-qemu-action@v3
with:
platforms: all
- uses: docker/setup-buildx-action@v3
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.setup.outputs.go_version }}
check-latest: true
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/go-cache
- id: setup-go
uses: actions/setup-go@v5
with:
go: ${{ steps.setup.outputs.go_version }}
go-version-file: go.mod
check-latest: true
- name: Warm cache
if: steps.setup-go.outputs.cache-hit != 'true'
run: |
# go mod download
find . -name go.mod -type f -execdir go mod download \;
- id: mod
run: ./.github/script/nightly-module.sh
- id: novelty
Expand All @@ -74,15 +70,15 @@ jobs:
username: ${{ secrets.QUAY_USER }}
password: ${{ secrets.QUAY_TOKEN }}
- name: Export
if: steps.novelty.outputs.cache-hit != 'true'
# This exports the current state of the main branch, and appends our modified go module files.
run: |
mkdir "${{ runner.temp }}/build"
git archive --add-file=go.mod --add-file=go.sum origin/main |
tar -x -C "${{ runner.temp }}/build"
- uses: docker/build-push-action@v5
if: steps.novelty.outputs.cache-hit != 'true'
with:
build-args: |
GO_VERSION=${{ env.GO_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max
context: ${{ runner.temp }}/build
Expand Down
Loading