Port CI to Github Actions

Most of the magic happens on the infra side:
https://forge.certus.one/c/infra/+/2105

commit-id:66aa537b
This commit is contained in:
Leo 2021-12-11 19:06:56 +01:00 committed by Leopold Schabel
parent 7e59627c96
commit a3b9760aca
4 changed files with 69 additions and 88 deletions

67
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,67 @@
name: Build
on:
workflow_dispatch:
pull_request:
push:
branches:
- dev.v2
- switch-to-gha # XXX
jobs:
# Run the full Tilt build and wait for it to converge
tilt:
runs-on: tilt-kube-public
# Cancel previous builds on the same branch/ref. Full runs are expensive
# and capacity is limited, so we want to avoid running multiple builds
# in parallel even if it means skipping CI runs on permanent branches
# (unfortunately, we can't differentiate between temporary and permanent
# refs without duplicating the entire logic).
concurrency:
group: tilt-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v2
- name: Expand for link to Tilt dashboard (only available during build)
run: >
echo "Tilt progress dashboard: https://$DASHBOARD_URL"
- run: |
kubectl config set-context ci --namespace=$DEPLOY_NS
kubectl config use-context ci
# TODO: Work around what is presumably a bug in the explorer Tilt code -
# Buildpack won't pull the image itself on a cold cache
# https://github.com/certusone/wormhole/issues/575
- run: docker pull gcr.io/buildpacks/builder:v1
- run: tilt ci -- --ci --namespace=$DEPLOY_NS --num=1
timeout-minutes: 60
# Clean up k8s resources
- run: kubectl delete --namespace=$DEPLOY_NS service,statefulset,configmap,pod --all
if: always()
# Verify whether the Makefile builds the node (no dependencies other than Go)
node:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.5'
- run: make node
# Run linters. This is just Go and Protobuf for now, but could include things
# like rustfmt as well.
lint:
# The linter is slow enough that we want to run it on the self-hosted runner
runs-on: tilt-kube-public
concurrency:
group: tilt-${{ github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.5'
- run: make generate && ./lint.sh

View File

@ -9,4 +9,4 @@ RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/i
sh -s -- -b ~ v1.42.0
RUN --mount=type=bind,target=/app,source=node cd /app && \
GOGC=off ~/golangci-lint run --skip-dirs pkg/supervisor ./...
GOGC=off ~/golangci-lint run --skip-dirs pkg/supervisor --timeout=10m ./...

View File

@ -1,86 +0,0 @@
final kubeCleanup = "kubectl delete --namespace=\$DEPLOY_NS service,statefulset,configmap,pod --all"
pipeline {
agent none
stages {
stage('Parallel') {
failFast true
parallel {
stage('Test') {
agent {
node {
label ""
customWorkspace '/home/ci/wormhole'
}
}
steps {
gerritCheck checks: ['jenkins:test': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
echo "Gerrit change: ${GERRIT_CHANGE_URL}"
echo "Tilt progress dashboard: https://${DASHBOARD_URL}"
sh """
kubectl config set-context ci --namespace=$DEPLOY_NS
kubectl config use-context ci
"""
sh kubeCleanup
timeout(time: 60, unit: 'MINUTES') {
sh "tilt ci -- --ci --namespace=$DEPLOY_NS --num=1"
}
timeout(time: 1, unit: 'MINUTES') {
sh "make node"
}
}
post {
success {
gerritCheck checks: ['jenkins:test': 'SUCCESSFUL']
}
unsuccessful {
gerritCheck checks: ['jenkins:test': 'FAILED']
}
cleanup {
sh kubeCleanup
}
}
}
stage('Lint') {
agent {
node {
label ""
customWorkspace '/home/ci/wormhole'
}
}
steps {
gerritCheck checks: ['jenkins:linters': 'RUNNING'], message: "Running on ${env.NODE_NAME}"
echo "Gerrit change: ${GERRIT_CHANGE_URL}"
timeout(time: 1, unit: 'MINUTES') {
sh "make generate"
sh "./lint.sh"
}
}
post {
success {
gerritCheck checks: ['jenkins:linters': 'SUCCESSFUL']
}
unsuccessful {
gerritCheck checks: ['jenkins:linters': 'FAILED']
}
}
}
}
post {
success {
gerritReview labels: [Verified: 1]
}
unsuccessful {
gerritReview labels: [Verified: -1]
}
}
}
}
}

View File

@ -1,3 +1,3 @@
#!/usr/bin/env bash
DOCKER_BUILDKIT=1 tilt docker build -- -f Dockerfile.lint .
DOCKER_BUILDKIT=1 docker build -f Dockerfile.lint .