Skip to content

Commit

Permalink
build: prevent bad commit messages, fix broken builds (#7086)
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Collins <alex_collins@intuit.com>
  • Loading branch information
alexec authored Oct 28, 2021
1 parent 93c11a2 commit 0fb1044
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 25 deletions.
19 changes: 13 additions & 6 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
Tips:
Don't bother creating a PR until you've done this:

* [ ] Run `make pre-commit -B` to fix codegen, lint, and commit message problems.

Create your PR as a draft.

* Maybe add you organization to [USERS.md](https://github.com/argoproj/argo-workflows/blob/master/USERS.md).
* Your PR needs to pass the required checks before it can be approved. If the check is not required (e.g. E2E tests) it does not need to pass
* Sign-off your commits to pass the DCO check: `git commit --signoff`.
* Run `make pre-commit -B` to fix codegen or lint problems.
* Your PR needs to pass the required checks before it can be approved. If the check is not required (e.g. E2E tests) it
does not need to pass.
* Once required tests have passed, you can make it "Ready for review".
* Say how how you tested your changes. If you changed the UI, attach screenshots.

Tips:

* If changes were requested, and you've made them, then dismiss the review to get it looked at again.
* You can ask for help!
* Add you organization to [USERS.md](https://github.com/argoproj/argo-workflows/blob/master/USERS.md) if you like.
* You can ask for help!
31 changes: 25 additions & 6 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ jobs:
- run: make server/static/files.go STATIC_FILES=false
- run: go build -v ./...
- run: make test STATIC_FILES=false GOTEST='go test -covermode=atomic -coverprofile=coverage.out'
# engineers just ignore this in PRs, so lets not even run it
- run: bash <(curl -s https://codecov.io/bash)
if: github.ref == 'refs/heads/master'

e2e-tests:
name: E2E Tests
Expand Down Expand Up @@ -91,9 +93,27 @@ jobs:
with:
path: /home/runner/go/bin
key: go-bin-v1-${{ hashFiles('**/go.mod') }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- uses: docker/setup-buildx-action@v1
- run: mkdir -p /tmp/log/argo-e2e
# we never want to pull images by accident on CI after we built them
# so imagePullPolicy=Never
# but, we can pull it if we don't need it
- run: docker pull quay.io/argoproj/argoexec:latest
if: ${{!(matrix.test == 'test-executor' || matrix.test == 'test-functional')}}
- name: make argoexec-image
if: ${{matrix.test == 'test-executor' || matrix.test == 'test-functional'}}
# retry this once, as it can be flakey
run: |
make argoexec-image STATIC_FILES=false || make argoexec-image STATIC_FILES=false
docker image prune -f
- name: Install and start K3S
timeout-minutes: 3
run: |
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.21.2+k3s1 INSTALL_K3S_CHANNEL=stable INSTALL_K3S_EXEC=--docker K3S_KUBECONFIG_MODE=644 sh -
until kubectl --kubeconfig=/etc/rancher/k3s/k3s.yaml cluster-info ; do sleep 10s ; done
Expand All @@ -110,21 +130,20 @@ jobs:
echo '127.0.0.1 mysql' | sudo tee -a /etc/hosts
- run: make install controller cli $(go env GOPATH)/bin/goreman PROFILE=${{matrix.profile}} E2E_EXECUTOR=${{matrix.containerRuntimeExecutor}} AUTH_MODE=client STATIC_FILES=false LOG_LEVEL=info
- run: make start PROFILE=${{matrix.profile}} E2E_EXECUTOR=${{matrix.containerRuntimeExecutor}} AUTH_MODE=client STATIC_FILES=false LOG_LEVEL=info UI=false > /tmp/log/argo-e2e/argo.log 2>&1 &
timeout-minutes: 4
- name: make argoexec-image
run: make argoexec-image STATIC_FILES=false
- run: make wait
timeout-minutes: 4
- run: make ${{matrix.test}} E2E_TIMEOUT=1m STATIC_FILES=false
- name: cat argo.log
if: ${{ failure() }}
run: cat /tmp/log/argo-e2e/argo.log

- name: MinIO logs
if: ${{ failure() }}
run: kubectl -n argo logs deploy/minio
codegen:
name: Codegen
runs-on: ubuntu-20.04
needs: [ tests ]
timeout-minutes: 9
timeout-minutes: 15
env:
GOPATH: /home/runner/go
PROTOC_ZIP: protoc-3.11.1-linux-x86_64.zip
Expand Down
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,13 @@ argoexec-image:

%-image:
[ ! -e dist/$* ] || mv dist/$* .
docker buildx build -t $(IMAGE_NAMESPACE)/$*:$(VERSION) --target $* --output=type=docker .
docker buildx install
docker build \
-t $(IMAGE_NAMESPACE)/$*:$(VERSION) \
--target $* \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output=type=docker .
[ ! -e $* ] || mv $* dist/
docker run --rm -t $(IMAGE_NAMESPACE)/$*:$(VERSION) version
if [ $(K3D) = true ]; then k3d image import $(IMAGE_NAMESPACE)/$*:$(VERSION); fi
Expand Down Expand Up @@ -376,7 +382,7 @@ test: server/static/files.go dist/argosay
env KUBECONFIG=/dev/null $(GOTEST) ./...

.PHONY: install
install:
install: githooks
kubectl get ns $(KUBE_NAMESPACE) || kubectl create ns $(KUBE_NAMESPACE)
kubectl config set-context --current --namespace=$(KUBE_NAMESPACE)
@echo "installing PROFILE=$(PROFILE), E2E_EXECUTOR=$(E2E_EXECUTOR)"
Expand Down Expand Up @@ -546,14 +552,14 @@ validate-examples: api/jsonschema/schema.json

# pre-push

.PHONY: pre-commit
pre-commit: codegen lint
.git/hooks/commit-msg: hack/git/hooks/commit-msg
cp -v hack/git/hooks/commit-msg .git/hooks/commit-msg

ifeq ($(GIT_BRANCH),master)
LOG_OPTS := '-n10'
else
LOG_OPTS := 'origin/master..'
endif
.PHONY: githooks
githooks: .git/hooks/commit-msg

.PHONY: pre-commit
pre-commit: githooks codegen lint

release-notes: /dev/null
version=$(VERSION) envsubst < hack/release-notes.md > release-notes
Expand Down
9 changes: 5 additions & 4 deletions docs/releases.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ Both the `argo-server` and `argocli` should be the same version as the controlle

# Release Cycle

For **stable**, use the latest patch version.
For **unstable**, we build and tag `latest` images for every commit to master.

New major versions are released roughly every 3 months. Release candidates for each major release are typically available
for 6 weeks before the release becomes generally available.
New minor versions are released roughly every 3 months. Release candidates for each major release are typically available
for 4-6 weeks before the release becomes generally available.

Otherwise, we typically release once a week:
Otherwise, we typically release weekly:

* Patch fixes for the current stable version. These are tagged `stable`.
* Patch fixes for the current stable version.
* The next release candidate, if we are currently in a release-cycle.
14 changes: 14 additions & 0 deletions hack/git/hooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
set -eu

grep -q 'Signed-off-by: ' "$1" || {
echo >&2 'Commits must be signed-off: https://probot.github.io/apps/dco/'
exit 1
}

grep -qE '^(?:feat|fix|docs|style|refactor|perf|test|chore)\(?(?:\w+|\s|\-|_)?\)?:\s\w+' "$1" || grep -q 'Merge' "$1" || {
echo >&2 'Commit message must be semantic: https://github.com/zeke/semantic-pull-requests'
exit 1
}

echo 'Your commit message is acceptable'

0 comments on commit 0fb1044

Please sign in to comment.