-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Benji Visser <[email protected]> Signed-off-by: shihanwan <[email protected]>
- Loading branch information
Showing
138 changed files
with
4,818 additions
and
3,954 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
name: "Bootstrap" | ||
description: "Bootstrap all tools and dependencies" | ||
inputs: | ||
go-version: | ||
description: "Go version to install" | ||
required: true | ||
default: "1.21.x" | ||
python-version: | ||
description: "Python version to install" | ||
required: true | ||
default: "3.10" | ||
use-go-cache: | ||
description: "Restore go cache" | ||
required: true | ||
default: "true" | ||
cache-key-prefix: | ||
description: "Prefix all cache keys with this value" | ||
required: true | ||
default: "831180ac25" | ||
build-cache-key-prefix: | ||
description: "Prefix build cache key with this value" | ||
required: true | ||
default: "f8b6d31dea" | ||
bootstrap-apt-packages: | ||
description: "Space delimited list of tools to install via apt" | ||
default: "libxml2-utils" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ inputs.go-version }} | ||
|
||
- uses: actions/setup-python@d27e3f3d7c64b4bbf8e4abfb9b63b83e846e0435 # v4.5.0 | ||
with: | ||
python-version: ${{ inputs.python-version }} | ||
|
||
- name: Restore python cache | ||
id: python-venv-cache | ||
uses: actions/cache@69d9d449aced6a2ede0bc19182fadc3a0a42d2b0 # v3.2.6 | ||
with: | ||
path: | | ||
test/quality/venv | ||
test/quality/vulnerability-match-labels/venv | ||
key: ${{ runner.os }}-python-${{ inputs.python-version }}-${{ hashFiles('**/test/quality/**/requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-python-${{ env.python-version }}- | ||
- name: Restore tool cache | ||
id: tool-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ github.workspace }}/.tmp | ||
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-tool-${{ hashFiles('Makefile') }} | ||
|
||
# note: we need to keep restoring the go mod cache before bootstrapping tools since `go install` is used in | ||
# some installations of project tools. | ||
- name: Restore go module cache | ||
id: go-mod-cache | ||
if: inputs.use-go-cache == 'true' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/go/pkg/mod | ||
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-go-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ inputs.cache-key-prefix }}-${{ runner.os }}-go-${{ inputs.go-version }}- | ||
- name: (cache-miss) Bootstrap project tools | ||
shell: bash | ||
if: steps.tool-cache.outputs.cache-hit != 'true' | ||
run: make bootstrap-tools | ||
|
||
- name: Restore go build cache | ||
id: go-cache | ||
if: inputs.use-go-cache == 'true' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.cache/go-build | ||
key: ${{ inputs.cache-key-prefix }}-${{ inputs.build-cache-key-prefix }}-${{ runner.os }}-go-${{ inputs.go-version }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ inputs.cache-key-prefix }}-${{ inputs.build-cache-key-prefix }}-${{ runner.os }}-go-${{ inputs.go-version }}- | ||
- name: (cache-miss) Bootstrap go dependencies | ||
shell: bash | ||
if: steps.go-mod-cache.outputs.cache-hit != 'true' && inputs.use-go-cache == 'true' | ||
run: make bootstrap-go | ||
|
||
- name: Install apt packages | ||
if: inputs.bootstrap-apt-packages != '' | ||
shell: bash | ||
run: | | ||
DEBIAN_FRONTEND=noninteractive sudo apt update && sudo -E apt install -y ${{ inputs.bootstrap-apt-packages }} | ||
- name: Create all cache fingerprints | ||
shell: bash | ||
run: make fingerprints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
red=$(tput setaf 1) | ||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
# assert we are running in CI (or die!) | ||
if [[ -z "$CI" ]]; then | ||
echo "${bold}${red}This step should ONLY be run in CI. Exiting...${normal}" | ||
exit 1 | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env python3 | ||
import subprocess | ||
import sys | ||
import shlex | ||
|
||
|
||
class bcolors: | ||
HEADER = '\033[95m' | ||
OKBLUE = '\033[94m' | ||
OKCYAN = '\033[96m' | ||
OKGREEN = '\033[92m' | ||
WARNING = '\033[93m' | ||
FAIL = '\033[91m' | ||
ENDC = '\033[0m' | ||
BOLD = '\033[1m' | ||
UNDERLINE = '\033[4m' | ||
|
||
|
||
if len(sys.argv) < 3: | ||
print("Usage: coverage.py [threshold] [go-coverage-report]") | ||
sys.exit(1) | ||
|
||
|
||
threshold = float(sys.argv[1]) | ||
report = sys.argv[2] | ||
|
||
|
||
args = shlex.split(f"go tool cover -func {report}") | ||
p = subprocess.run(args, capture_output=True, text=True) | ||
|
||
percent_coverage = float(p.stdout.splitlines()[-1].split()[-1].replace("%", "")) | ||
print(f"{bcolors.BOLD}Coverage: {percent_coverage}%{bcolors.ENDC}") | ||
|
||
if percent_coverage < threshold: | ||
print(f"{bcolors.BOLD}{bcolors.FAIL}Coverage below threshold of {threshold}%{bcolors.ENDC}") | ||
sys.exit(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
set -eu | ||
|
||
bold=$(tput bold) | ||
normal=$(tput sgr0) | ||
|
||
if ! [ -x "$(command -v gh)" ]; then | ||
echo "The GitHub CLI could not be found. To continue follow the instructions at https://github.com/cli/cli#installation" | ||
exit 1 | ||
fi | ||
|
||
gh auth status | ||
|
||
# we need all of the git state to determine the next version. Since tagging is done by | ||
# the release pipeline it is possible to not have all of the tags from previous releases. | ||
git fetch --tags | ||
|
||
# populates the CHANGELOG.md and VERSION files | ||
echo "${bold}Generating changelog...${normal}" | ||
make changelog 2> /dev/null | ||
|
||
NEXT_VERSION=$(cat VERSION) | ||
|
||
if [[ "$NEXT_VERSION" == "" || "${NEXT_VERSION}" == "(Unreleased)" ]]; then | ||
echo "Could not determine the next version to release. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
while true; do | ||
read -p "${bold}Do you want to trigger a release for version '${NEXT_VERSION}'?${normal} [y/n] " yn | ||
case $yn in | ||
[Yy]* ) echo; break;; | ||
[Nn]* ) echo; echo "Cancelling release..."; exit;; | ||
* ) echo "Please answer yes or no.";; | ||
esac | ||
done | ||
|
||
echo "${bold}Kicking off release for ${NEXT_VERSION}${normal}..." | ||
echo | ||
gh workflow run release.yaml -f version=${NEXT_VERSION} | ||
|
||
echo | ||
echo "${bold}Waiting for release to start...${normal}" | ||
sleep 10 | ||
|
||
set +e | ||
|
||
echo "${bold}Head to the release workflow to monitor the release:${normal} $(gh run list --workflow=release.yaml --limit=1 --json url --jq '.[].url')" | ||
id=$(gh run list --workflow=release.yaml --limit=1 --json databaseId --jq '.[].databaseId') | ||
gh run watch $id --exit-status || (echo ; echo "${bold}Logs of failed step:${normal}" && GH_PAGER="" gh run view $id --log-failed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
GO_VERSION: "1.20.x" | ||
GO_VERSION: "1.21.x" | ||
|
||
permissions: | ||
contents: read | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ on: | |
workflow_dispatch: | ||
|
||
env: | ||
GO_VERSION: "1.20.x" | ||
GO_VERSION: "1.21.x" | ||
|
||
permissions: | ||
contents: read | ||
|
Oops, something went wrong.