-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update Makefile to use `go install` instead of `go get` - Use script to install kustomize (go install not supported) - Update manifests to use ko-enabled image references - Add make target to install ko, update Makefile to build and deploy with ko. - Fix namings - Use label shipwright.io/component, value "triggers" to group the deployment and services together. - Use shipwright-triggers as prefix - Rename deployment to "controller" - Add end to end test to ensure the deployment works correctly. - Add documentation on how to build, deploy, and test Triggers in a local development environment. - Add pull request template. - Add GitHub action to lint release notes, draft a release, and run CI tests.
- Loading branch information
1 parent
e7eb2cc
commit 3b0091c
Showing
19 changed files
with
629 additions
and
62 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,141 @@ | ||
#! /bin/bash | ||
# Copyright The Shipwright Contributors | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# this script assumes the GITHUB_TOKEN and PREVIOUS_TAG environment variables have been set; | ||
# it produces a 'Changes.md' file as its final output; | ||
# the file 'last-300-prs-with-release-note.txt' that is produces is intermediate data; it is not | ||
# pruned for now to assist development of the release notes process (we are still curating all this) | ||
|
||
if [ -z ${GITHUB_TOKEN+x} ]; then | ||
echo "Error: GITHUB_TOKEN is not set" | ||
fi | ||
if [ -z ${PREVIOUS_TAG+x} ]; then | ||
echo "Error: PREVIOUS_TAG is not set" | ||
fi | ||
|
||
sudo apt-get -y update | ||
sudo apt-get -y install wget curl git | ||
curl -L https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz | tar xzf - | ||
PWD="$(pwd)" | ||
export PATH=$PWD/hub-linux-amd64-2.14.2/bin:$PATH | ||
git fetch --all --tags --prune --force | ||
echo "# Draft Release changes since ${PREVIOUS_TAG}" > Changes.md | ||
echo > Features.md | ||
echo "## Features" >> Features.md | ||
echo > Fixes.md | ||
echo "## Fixes" >> Fixes.md | ||
echo > API.md | ||
echo "## API Changes" >> API.md | ||
echo > Docs.md | ||
echo "## Docs" >> Docs.md | ||
echo > Misc.md | ||
echo "## Misc" >> Misc.md | ||
|
||
# this effectively gets the commit associated with github.event.inputs.tags | ||
COMMON_ANCESTOR=$(git merge-base $PREVIOUS_TAG HEAD) | ||
echo "COMMON_ANCESTOR is ${COMMON_ANCESTOR}" | ||
# in theory the new tag has not been created yet; do we want another input that specifies the existing | ||
# commit desired for drafting the release? for now, we are using HEAD in the above git merge-base call | ||
# and PR cross referencing below | ||
|
||
# use of 'hub', which is an extension of the 'git' CLI, allows for pulling of PRs, though we can't search based on commits | ||
# associated with those PRs, so we grab a super big number, 300, which should guarantee grabbing all the PRs back to | ||
# github.events.inputs.tags; we use grep -v to filter out release-note-none. | ||
# NOTE: investigated using the new 'gh' cli command, but its 'gh pr list' does not currently support the -f option so | ||
# staying with 'hub' for now. | ||
hub pr list --state merged -L 300 -f "%sm;%au;%i;%t;%L%n" | grep -E ", release-note|release-note," | grep -v release-note-none > last-300-prs-with-release-note.txt | ||
# this is for debug while we sort out env differences between Gabe's fedora and GitHub Actions' ubuntu | ||
echo "start dump last-300-prs-with-release-note.txt for potential debug" | ||
cat last-300-prs-with-release-note.txt | ||
echo "end dump last-300-prs-with-release-note.txt for potential debug" | ||
# now we cylce through last-300-prs-with-release-note.txt, filtering out stuff that is too old or other anomalies, | ||
# and update Changes.md with the release note. | ||
while IFS= read -r pr; do | ||
SHA=$(echo $pr | cut -d';' -f1) | ||
|
||
# skip the common ancestor, which in essences is the commit associated with the tag github.event.inputs.tags | ||
if [ "$SHA" == "$COMMON_ANCESTOR" ]; then | ||
continue | ||
fi | ||
|
||
# stylistic clarification, purposefully avoiding slicker / cleverer / more compact scripting conventions | ||
|
||
# this makes sure that this PR has merged | ||
git merge-base --is-ancestor $SHA HEAD | ||
rc=$? | ||
if [ ${rc} -eq 1 ]; then | ||
continue | ||
fi | ||
# otherwise, if the current commit from the last 300 PRs is not an ancestor of github.event.inputs.tags, we have gone too far, so skip | ||
git merge-base --is-ancestor $COMMON_ANCESTOR $SHA | ||
rc=$? | ||
if [ ${rc} -eq 1 ]; then | ||
continue | ||
fi | ||
# if we are at this point, we have a PR with a release note to add | ||
AUTHOR=$(echo $pr | cut -d';' -f2) | ||
PR_NUM=$(echo $pr | cut -d';' -f3) | ||
echo "Examining from @${AUTHOR} PR ${PR_NUM}" | ||
PR_BODY=$(wget -q -O- https://api.github.com/repos/shipwright-io/triggers/issues/${PR_NUM:1}) | ||
echo $PR_BODY | grep -oPz '(?s)(?<=```release-note..)(.+?)(?=```)' > /dev/null 2>&1 | ||
rc=$? | ||
if [ ${rc} -eq 1 ]; then | ||
echo "First validation: the release-note field for PR ${PR_NUM} was not properly formatted. Until it is fixed, it will be skipped for release note inclusion." | ||
echo "See the PR template at https://raw.githubusercontent.com/shipwright-io/triggers/master/.github/pull_request_template.md for verification steps" | ||
continue | ||
fi | ||
PR_BODY_FILTER_ONE=$(echo $PR_BODY | grep -oPz '(?s)(?<=```release-note..)(.+?)(?=```)') | ||
echo $PR_BODY_FILTER_ONE | grep -avP '\W*(Your release note here|NONE)\W*' > /dev/null 2>&1 | ||
rc=$? | ||
if [ ${rc} -eq 1 ]; then | ||
echo "Second validation: the release-note field for PR ${PR_NUM} was not properly formatted. Until it is fixed, it will be skipped for release note inclusion." | ||
echo "See the PR template at https://raw.githubusercontent.com/shipwright-io/triggers/master/.github/pull_request_template.md for verification steps" | ||
continue | ||
fi | ||
PR_RELEASE_NOTE=$(echo $PR_BODY_FILTER_ONE | grep -avP '\W*(Your release note here|NONE)\W*') | ||
PR_RELEASE_NOTE_NO_NEWLINES=$(echo $PR_RELEASE_NOTE | sed 's/\\n//g' | sed 's/\\r//g') | ||
MISC=yes | ||
echo $pr | grep 'kind/bug' | ||
rc=$? | ||
if [ ${rc} -eq 0 ]; then | ||
echo >> Fixes.md | ||
echo "$PR_NUM by @$AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Fixes.md | ||
MISC=no | ||
fi | ||
echo $pr | grep 'kind/api-change' | ||
rc=$? | ||
if [ ${rc} -eq 0 ]; then | ||
echo >> API.md | ||
echo "$PR_NUM by @$AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> API.md | ||
MISC=no | ||
fi | ||
echo $pr | grep 'kind/feature' | ||
rc=$? | ||
if [ ${rc} -eq 0 ]; then | ||
echo >> Features.md | ||
echo "$PR_NUM by @$AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Features.md | ||
MISC=no | ||
fi | ||
echo $pr | grep 'kind/documentation' | ||
rc=$? | ||
if [ ${rc} -eq 0 ]; then | ||
echo >> Docs.md | ||
echo "$PR_NUM by @$AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Docs.md | ||
MISC=no | ||
fi | ||
if [ "$MISC" == "yes" ]; then | ||
echo >> Misc.md | ||
echo "$PR_NUM by @$AUTHOR: $PR_RELEASE_NOTE_NO_NEWLINES" >> Misc.md | ||
fi | ||
# update the PR template if our greps etc. for pulling the release note changes | ||
#PR_RELEASE_NOTE=$(wget -q -O- https://api.github.com/repos/shipwright-io/triggers/issues/${PR_NUM:1} | grep -oPz '(?s)(?<=```release-note..)(.+?)(?=```)' | grep -avP '\W*(Your release note here|action required: your release note here|NONE)\W*') | ||
echo "Added from @${AUTHOR} PR ${PR_NUM:1} to the release note draft" | ||
done < last-300-prs-with-release-note.txt | ||
|
||
cat Features.md >> Changes.md | ||
cat Fixes.md >> Changes.md | ||
cat API.md >> Changes.md | ||
cat Docs.md >> Changes.md | ||
cat Misc.md >> Changes.md |
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,52 @@ | ||
# Changes | ||
|
||
<!-- 🎉🎉🎉 Thank you for the PR!!! 🎉🎉🎉 --> | ||
|
||
<!-- Describe your changes here- ideally you can get that description straight from | ||
your descriptive commit message(s)! --> | ||
|
||
<!-- If this PR fixes a GitHub issue, please mention it like so: | ||
Fixes #<insert issue number here> | ||
--> | ||
|
||
# Submitter Checklist | ||
|
||
- [ ] Includes tests if functionality changed/was added | ||
- [ ] Includes docs if changes are user-facing | ||
- [ ] [Set a kind label on this PR](https://prow.k8s.io/command-help#kind) | ||
- [ ] Release notes block has been filled in, or marked NONE | ||
|
||
See [the contributor guide](https://github.com/shipwright-io/build/blob/main/CONTRIBUTING.md) | ||
for details on coding conventions, github and prow interactions, and the code review process. | ||
|
||
# Release Notes | ||
|
||
<!-- | ||
Describe any user facing changes here, or delete this block. | ||
Examples of user facing changes: | ||
- API changes | ||
- Bug fixes | ||
- Any changes in behavior | ||
- Changes requiring upgrade notices or deprecation warnings | ||
For pull requests with a release note: | ||
```release-note | ||
Your release note here | ||
``` | ||
For pull requests that require additional action from users switching to the new release, include the string "action required" (case insensitive) in the release note: | ||
```release-note | ||
action required: your release note here | ||
``` | ||
For pull requests that don't need to be mentioned at release time, use the `/release-note-none` Prow command to add the `release-note-none` label to the PR. You can also write the string "NONE" as a release note in your PR description: | ||
```release-note | ||
NONE | ||
``` | ||
--> |
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,81 @@ | ||
on: | ||
pull_request: | ||
branches: [ main ] | ||
push: | ||
branches: [ main ] | ||
name: ci/github | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
# test: | ||
# strategy: | ||
# matrix: | ||
# go-version: [1.17.x] | ||
# os: [ubuntu-latest] | ||
# runs-on: ${{ matrix.os }} | ||
# steps: | ||
# - name: Install Go | ||
# uses: actions/setup-go@v2 | ||
# with: | ||
# go-version: ${{ matrix.go-version }} | ||
# - name: Check out code | ||
# uses: actions/checkout@v2 | ||
# - name: Unit Test | ||
# run: make test | ||
# - name: Integration Test | ||
# run: make test-integration | ||
e2e: | ||
strategy: | ||
matrix: | ||
kubernetes: [v1.21.2] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Install kubectl | ||
uses: azure/setup-kubectl@v1 | ||
with: | ||
version: ${{ matrix.kubernetes }} | ||
- name: Install Ko | ||
# This sha corresponds to v0.4 | ||
uses: imjasonh/setup-ko@2c3450ca27f6e6f2b02e72a40f2163c281a1f675 | ||
with: | ||
version: v0.11.2 | ||
- name: Create kind cluster | ||
uses: helm/[email protected] | ||
with: | ||
version: v0.11.1 | ||
node_image: kindest/node:${{ matrix.kubernetes }} | ||
cluster_name: kind | ||
config: test/e2e/testdata/kind.yaml | ||
wait: 120s | ||
- name: Verify kind cluster | ||
run: | | ||
echo "# Using KinD context..." | ||
kubectl config use-context "kind-kind" | ||
echo "# KinD nodes:" | ||
kubectl get nodes | ||
NODE_STATUS=$(kubectl get node kind-control-plane -o json | jq -r .'status.conditions[] | select(.type == "Ready") | .status') | ||
if [ "${NODE_STATUS}" != "True" ]; then | ||
echo "# Node is not ready:" | ||
kubectl describe node kind-control-plane | ||
echo "# Pods:" | ||
kubectl get pod -A | ||
echo "# Events:" | ||
kubectl get events -A | ||
exit 1 | ||
fi | ||
- name: Install Shipwight Build | ||
run: | | ||
kubectl apply -f https://github.com/shipwright-io/build/releases/download/v0.9.0/release.yaml | ||
kubectl apply -f https://github.com/shipwright-io/build/releases/download/v0.9.0/sample-strategies.yaml | ||
- name: Deploy | ||
run: make deploy KO=/usr/local/bin/ko IMAGE_REPO=kind.local | ||
- name: Test | ||
run: make test-e2e |
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,40 @@ | ||
--- | ||
name: Release Note Linter | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Release Note Linter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Sanity Check Release Notes | ||
if: github.actor != 'dependabot[bot]' | ||
env: | ||
PR_NUMBER: ${{ github.event.number }} | ||
run: | | ||
# Validate PR release notes | ||
echo "Going to validate PR ${PR_NUMBER}" | ||
echo "First making sure you have not left the PR template as is" | ||
# Describe any user facing changes here, or delete this block. | ||
TEMPLATE_LEFT_AS_IS=$(wget -q -O- https://api.github.com/repos/shipwright-io/triggers/pulls/${PR_NUMBER} | jq '.body | match("(Describe any user facing changes here, or delete this block)")') | ||
if [ -z "${TEMPLATE_LEFT_AS_IS}" ]; then | ||
echo "You appear to have attempted to update the PR template to define a release note." | ||
else | ||
echo "You have not made any changes for release notes in your PR description. Edit your PR description per the instructions at https://raw.githubusercontent.com/shipwright-io/triggers/main/.github/pull_request_template.md" | ||
exit 1 | ||
fi | ||
echo "Now checking against valid structure for release notes" | ||
MATCHES=$(wget -q -O- https://api.github.com/repos/shipwright-io/triggers/pulls/${PR_NUMBER} | jq '.body | match("(```release-note\r\n(.*|NONE|action required: .*)\r\n```)")') | ||
if [ -z "${MATCHES}" ]; then | ||
echo "Your Release Notes were not properly defined or they are not in place, please make sure you add them." | ||
echo "See our PR template for more information: https://raw.githubusercontent.com/shipwright-io/triggers/main/.github/pull_request_template.md" | ||
exit 1 | ||
else | ||
echo "Your Release Notes are properly in place!" | ||
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,55 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release: | ||
description: 'Desired tag' | ||
required: true | ||
tags: | ||
description: 'Previous tag' | ||
required: true | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
id-token: write # To be able to get OIDC ID token to sign images. | ||
contents: write # To be able to update releases. | ||
packages: write # To be able to push images and signatures. | ||
pull-requests: write # To be able to create pull requests | ||
env: | ||
IMAGE_HOST: ghcr.io | ||
IMAGE_NAMESPACE: ${{ github.repository }} | ||
TAG: ${{ github.event.inputs.release }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # Fetch all history, needed for release note generation. | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.x | ||
|
||
- name: Build Release Changelog | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
PREVIOUS_TAG: ${{ github.event.inputs.tags }} | ||
run: | | ||
# might not be necessary but make sure | ||
chmod +x "${GITHUB_WORKSPACE}/.github/draft_release_notes.sh" | ||
export GITHUB_TOKEN | ||
export PREVIOUS_TAG | ||
"${GITHUB_WORKSPACE}/.github/draft_release_notes.sh" | ||
- name: Draft release | ||
id: draft_release | ||
uses: actions/create-release@v1 | ||
with: | ||
release_name: "${{ github.event.inputs.release }}" | ||
tag_name: ${{ github.event.inputs.release }} | ||
body_path: Changes.md | ||
draft: true | ||
prerelease: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Binaries for development | ||
bin/ |
Oops, something went wrong.