Skip to content

CI Workflow

CI Workflow #3319

Workflow file for this run

---
name: CI Workflow
on:
push:
branches:
- main
schedule:
- cron: "5 0 * * *" # TODO: Run every 4 hours to soak test, should be less frequent before merge (weekly/daily/???)
workflow_dispatch:
env:
IMAGE_NAME: cluster-api-provider-packet
GHCR_REGISTRY: ghcr.io/${{ github.repository_owner }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_ORG }}
QUAY_REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
validate:
name: "Validate ${{ matrix.target }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["verify", "lint", "test"]
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}
build-image:
name: Build and Push Image
runs-on: ubuntu-latest
permissions:
packages: write # needed to push docker image to ghcr.io
pull-requests: write # needed to create and update comments in PRs
steps:
- name: Checkout git repo
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 ghcr.io registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into DockerHub
uses: docker/login-action@v3
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
if: ${{ env.DOCKER_USERNAME != '' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log into quay.io
uses: docker/login-action@v3
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
if: ${{ env.QUAY_USERNAME != '' }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.QUAY_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=edge
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,priority=1001
- name: Docker Build and Push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
# If PR, put image tags in the PR comments
# from https://github.com/marketplace/actions/create-or-update-comment
- name: Find comment for image tags
uses: peter-evans/find-comment@v3
if: github.event_name == 'pull_request'
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Docker image tag(s) pushed
# If PR, put image tags in the PR comments
- name: Create or update comment for image tags
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'pull_request'
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Docker image tag(s) pushed:
```text
${{ steps.docker_meta.outputs.tags }}
```
Labels added to images:
```text
${{ steps.docker_meta.outputs.labels }}
```
edit-mode: replace
outputs:
image-tag: "${{ steps.docker_meta.outputs.version }}"
release-manifests:
name: Make Release Manifests
runs-on: ubuntu-latest
needs: [build-image]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Make Release
run: make release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release-manifests
path: out/release
e2e-quickstart:
name: "E2E quickstart"
concurrency: ci-${{ github.ref }}-e2e-quickstart
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e-quickstart"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi-quickstart.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-quickstart
path: _artifacts
e2e:
name: "E2E"
concurrency: ci-${{ github.ref }}-e2e
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e
path: _artifacts
e2e-conformance:
name: "E2E conformance"
concurrency: ci-${{ github.ref }}-e2e-conformance
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e-conformance"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi-conformance.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-conformance
path: _artifacts
e2e-workload-upgrade:
name: "E2E Workload-Upgrade"
concurrency: ci-${{ github.ref }}-e2e-workload-upgrade
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e-workload-upgrade"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi-workload-upgrade.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-workload-upgrade
path: _artifacts