Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GH Actions + Refactors #48

Merged
merged 7 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/buildtest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: go-build-and-test-amd64
on:
push:
pull_request:
schedule:
- cron: "0 8 * * 0" # every sunday
jobs:
build:
name: build
strategy:
matrix:
go-version: [1.20.x]
os: [ubuntu-latest]
goos: [linux]
goarch: [amd64]
runs-on: ${{ matrix.os }}
steps:
- name: set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: check out code into the Go module directory
uses: actions/checkout@v2
- name: build test for ${{ matrix.goarch }}
env:
GOARCH: ${{ matrix.goarch }}
GOOS: ${{ matrix.goos }}
run: make build

test:
name: test
runs-on: ubuntu-latest
needs: build
steps:
- name: set up Go
uses: actions/setup-go@v3
with:
go-version: 1.20.x
- name: check out code into the Go module directory
uses: actions/checkout@v3
- name: run unit-test
run: make test
41 changes: 41 additions & 0 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "37 4 * * 0"

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ go ]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality

- name: Autobuild
uses: github/codeql-action/autobuild@v2

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
126 changes: 126 additions & 0 deletions .github/workflows/image-push-master.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: "push images on merge to master"

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}

on:
push:
branches:
- master
jobs:
build-and-push-amd64-rdma-cni:
name: image push amd64
runs-on: ubuntu-20.04
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why not to use ubuntu-latest

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

essentially copied either from sriov-cni or sriov-device-plugin.

maybe for stability ? so u know what u get when building image.

that said. i can change to latest if u think it better :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it good to pin it, what go me confused is that the build and test are on ubunut-latest.
Maybe we should move all to ubuntu-22.04

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. will pin all and move to 22.04.

steps:
- name: check out the repo
uses: actions/checkout@v2

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: build and push rdma-cni
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64
tags: |
${{ env.IMAGE_NAME }}:latest-amd64
${{ steps.docker_meta.outputs.tags }}:${{ github.sha }}
file: ./Dockerfile

build-and-push-arm64-rdma-cni:
name: image push arm64
runs-on: ubuntu-20.04
steps:
- name: check out the repo
uses: actions/checkout@v2

- name: set up QEMU
uses: docker/setup-qemu-action@v1

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: build and push rdma-cni
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/arm64
tags: |
${{ env.IMAGE_NAME }}:latest-arm64
file: ./Dockerfile.arm64

build-and-push-ppc64le-rdma-cni:
name: image Push ppc64le
runs-on: ubuntu-20.04
steps:
- name: check out the repo
uses: actions/checkout@v2

- name: set up QEMU
uses: docker/setup-qemu-action@v1

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: build and push rdma-cni
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/ppc64le
tags: |
${{ env.IMAGE_NAME }}:latest-ppc64le
file: ./Dockerfile.ppc64le

push-manifest:
runs-on: ubuntu-20.04
needs: [build-and-push-amd64-rdma-cni,build-and-push-amr64-rdma-cni,build-and-push-ppc64le-rdma-cni]
steps:
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create manifest for multi-arch images
run: |
# pull
docker pull ${{ env.IMAGE_NAME }}:latest-amd64
docker pull ${{ env.IMAGE_NAME }}:latest-arm64
docker pull ${{ env.IMAGE_NAME }}:latest-ppc64le
# create
docker manifest create ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-amd64 ${{ env.IMAGE_NAME }}:latest-arm64 ${{ env.IMAGE_NAME }}:latest-ppc64le
# annotate
docker manifest annotate ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-amd64 --arch amd64
docker manifest annotate ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-arm64 --arch arm64
docker manifest annotate ${{ env.IMAGE_NAME }}:latest ${{ env.IMAGE_NAME }}:latest-ppc64le --arch ppc64le
# push
docker manifest push ${{ env.IMAGE_NAME }}:latest
148 changes: 148 additions & 0 deletions .github/workflows/image-push-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
name: "push images on release"

env:
IMAGE_NAME: ghcr.io/${{ github.repository }}

on:
push:
tags:
- v*
jobs:
build-and-push-amd64-rdma-cni:
runs-on: ubuntu-20.04
name: image push AMD64
steps:
- name: check out the repo
uses: actions/checkout@v2

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

- name: build and push rdma-cni
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/amd64
tags: |
${{ steps.docker_meta.outputs.tags }}-amd64
${{ steps.docker_meta.outputs.tags }}:${{ github.sha }}
file: ./Dockerfile

build-and-push-arm64-rdma-cni:
runs-on: ubuntu-20.04
name: image push ARM64
steps:
- name: check out the repo
uses: actions/checkout@v2

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

- name: build and push rdma-cni
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/arm64
tags: |
${{ steps.docker_meta.outputs.tags }}-arm64
file: ./Dockerfile.arm64

build-and-push-ppc64le-rdma-cni:
runs-on: ubuntu-20.04
name: image push ppc64le
steps:
- name: check out the repo
uses: actions/checkout@v2

- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

- name: build and push rdma-cni
uses: docker/build-push-action@v2
with:
context: .
push: true
platforms: linux/arm64
tags: |
${{ steps.docker_meta.outputs.tags }}-ppc64le
file: ./Dockerfile.ppc64le

push-manifest:
runs-on: ubuntu-20.04
needs: [build-and-push-amd64-rdma-cni,build-and-push-amr64-rdma-cni,build-and-push-ppc64le-rdma-cni]
steps:
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: ${{ env.IMAGE_NAME }}
tag-latest: false

- name: login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: create manifest for multi-arch images
run: |
# pull
docker pull ${{ steps.docker_meta.outputs.tags }}-amd64
docker pull ${{ steps.docker_meta.outputs.tags }}-arm64
docker pull ${{ steps.docker_meta.outputs.tags }}-ppc64le
# create
docker manifest create ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64 ${{ steps.docker_meta.outputs.tags }}-arm64 ${{ steps.docker_meta.outputs.tags }}-ppc64le
# annotate
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-amd64 --arch amd64
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-arm64 --arch arm64
docker manifest annotate ${{ steps.docker_meta.outputs.tags }} ${{ steps.docker_meta.outputs.tags }}-ppc64le --arch ppc64le
# push
docker manifest push ${{ steps.docker_meta.outputs.tags }}
33 changes: 33 additions & 0 deletions .github/workflows/static-scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: go-static-analysis
on: [push, pull_request]
jobs:
golangci:
name: Lint
runs-on: ubuntu-latest
steps:
- name: set up Go
uses: actions/setup-go@v3
with:
go-version: "1.20"
- name: checkout PR
uses: actions/checkout@v2
- name: run make lint
run: make lint
shellcheck:
name: shellcheck
runs-on: ubuntu-latest
steps:
- name: checkout PR
uses: actions/checkout@v2
- name: run ShellCheck
uses: ludeeus/action-shellcheck@master
hadolint:
runs-on: ubuntu-latest
name: Hadolint
steps:
- name: checkout PR
uses: actions/checkout@v2
- name: run Hadolint
uses: brpaz/[email protected]
with:
dockerfile: Dockerfile