Skip to content

✨ Reimplement GCP connection draining #247

✨ Reimplement GCP connection draining

✨ Reimplement GCP connection draining #247

Workflow file for this run

name: ci
# Trigger on push to main branch and any pull requests to main branch
on:
push:
branches:
- main
tags:
# Match semantic version tags:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#patterns-to-match-branches-and-tags
- v[0-9]+.[0-9]+.[0-9]+
pull_request:
branches:
- main
# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#comments-and-annotations
permissions:
contents: read
pull-requests: read
checks: write
jobs:
# https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --timeout=10m
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '1.21'
- run: go mod download
- name: Verify generated code
run: make verify
- name: Run unit tests
run: make test
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Build without pushing to first validate that the image works as expected:
# https://docs.docker.com/build/ci/github-actions/test-before-push/
- name: Build Docker image
uses: docker/build-push-action@v5
id: docker-build
with:
context: .
platforms: linux/amd64
tags: docker.io/dippynark/cost-manager:test
cache-from: type=gha
cache-to: type=gha,mode=max
# Export to Docker so we can load into kind cluster:
# https://docs.docker.com/build/ci/github-actions/export-docker/
load: true
- name: Setup Helm
uses: azure/setup-helm@v3
with:
version: v3.12.1
- name: Helm lint
run: helm lint --strict ./charts/cost-manager
- name: Install kind
uses: helm/[email protected]
with:
install_only: true
- name: Run E2E tests
run: make e2e IMAGE=${{ fromJSON(steps.docker-build.outputs.metadata)['image.name'] }}
release:
# Make sure the tests have passed before releasing
needs:
- lint
- test
runs-on: ubuntu-latest
# Do not release for forked repositories since secrets are not available:
# https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions#using-secrets-in-a-workflow
if: ${{ ! github.event.pull_request.head.repo.fork }}
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
id: docker-login
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# https://github.com/docker/metadata-action#basic
- name: Docker meta
uses: docker/metadata-action@v5
id: meta
with:
images: docker.io/dippynark/cost-manager
# Do not handle the latest tag by default. In particular this prevents the latest tag being
# pushed when the repository is tagged with a semantic version:
# https://github.com/docker/metadata-action#flavor-input
flavor: latest=false
tags: |
# Push semantic version tags: https://github.com/docker/metadata-action#typesemver
type=semver,pattern={{raw}}
# To make sure that we cannot accidentally push a semantic version tag from a pull request
# we only generate tags from the pull request number:
# https://github.com/docker/metadata-action#typeref
type=ref,event=pr
# Set the latest tag for the main branch:
# https://github.com/docker/metadata-action#latest-tag
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
# Buildx does not currently support pushing a previously built image so we rebuild from cache:
# https://github.com/docker/buildx/issues/1915
- name: Push Docker image
uses: docker/build-push-action@v5
with:
context: .
# We do not build the ARM64 image for pull requests since it takes a very long time:
# https://github.com/docker/setup-qemu-action/issues/22
# https://github.com/DSpace/DSpace/pull/8315
platforms: linux/amd64${{ github.event_name != 'pull_request' && ',linux/arm64' || '' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: true