Skip to content

Commit

Permalink
add ci (testing and container builds) (#8)
Browse files Browse the repository at this point in the history
* add ci (testing and container builds)
* helmify binary missing

Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch committed Nov 5, 2023
1 parent d4114cd commit 8f8cb82
Show file tree
Hide file tree
Showing 27 changed files with 2,376 additions and 6 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/build-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: build oras-operator

on:
pull_request: []
push:
branches:
- main
workflow_dispatch:

jobs:
# Only build arm image on merge, takes too long otherwise
build-arm:
if: (github.event_name != 'pull_request')
runs-on: ubuntu-latest
name: make and build arm
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: GHCR Login
if: (github.event_name != 'pull_request')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Add custom buildx ARM builder
run: |
docker buildx create --name armbuilder
docker buildx use armbuilder
docker buildx inspect --bootstrap
- name: Deploy Container
run: make arm-deploy

build:
runs-on: ubuntu-latest
strategy:
matrix:
command: [docker]

name: make and build ${{ matrix.command }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: GHCR Login
if: (github.event_name != 'pull_request')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Container
run: make ${{ matrix.command }}-build

- name: Deploy Container
if: (github.event_name != 'pull_request')
run: make ${{ matrix.command }}-push
47 changes: 47 additions & 0 deletions .github/workflows/helm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: helm oras-operator

on:
pull_request: []
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
name: Prepare chart
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: GHCR Login
if: (github.event_name != 'pull_request')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install Helm
run: |
export HELM_EXPERIMENTAL_OCI=1
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Build chart
run: make helm

- name: Login to Helm
if: (github.event_name != 'pull_request')
env:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "${password}" | helm registry login -u ${username} --password-stdin ${registry}
PKG_RESPONSE=$(helm package ./chart)
echo "$PKG_RESPONSE"
CHART_TAR_GZ=$(basename "$PKG_RESPONSE")
helm push "$CHART_TAR_GZ" oci://ghcr.io/converged-computing/oras-operator-helm
47 changes: 47 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: test oras-operator

on:
pull_request: []

jobs:
formatting:
name: Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup black linter
run: conda create --quiet --name black pyflakes

- name: Check Spelling
uses: crate-ci/typos@7ad296c72fa8265059cc03d1eda562fbdfcd6df2 # v1.9.0
with:
files: ./README.md ./docs/*.md ./docs/*/*.md ./docs/*/*/*.md

unit-tests:
name: Unit Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: fmt check
run: make fmt

# These aren't written yet
- name: Run Unit tests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make test

# Ensure build-config is the same as the one we have
- name: Check Updated oras-operator.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cp examples/dist/oras-operator.yaml /tmp/oras-operator.yaml
make build-config
diff examples/dist/oras-operator.yaml /tmp/oras-operator.yaml
111 changes: 111 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: oras operator tag and release

on:
workflow_dispatch:
inputs:
release_tag:
description: Custom release tag
type: string
required: true

jobs:
build-arm:
runs-on: ubuntu-latest
name: make and build arm
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set tag
run: |
echo "Tag for release is ${{ inputs.release_tag }}"
echo "tag=${{ inputs.release_tag }}" >> ${GITHUB_ENV}
- uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: GHCR Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Add custom buildx ARM builder
run: |
docker buildx create --name armbuilder
docker buildx use armbuilder
docker buildx inspect --bootstrap
- name: Deploy Container
env:
tag: ${{ env.tag }}
run: make arm-deploy ARMIMG=ghcr.io/converged-computing/oras-operator:${tag}-arm

build:
runs-on: ubuntu-latest
strategy:
matrix:
command: [docker]
name: make and build ${{ matrix.command }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: ^1.20
- name: Set tag
run: |
echo "Tag for release is ${{ inputs.release_tag }}"
echo "tag=${{ inputs.release_tag }}" >> ${GITHUB_ENV}
- name: GHCR Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Container
env:
tag: ${{ env.tag }}
run: |
image=ghcr.io/converged-computing/oras-operator-${{ matrix.command }}:v${tag}
img=ghcr.io/converged-computing/oras-operator:v${tag}
make ${{ matrix.command }}-build BUNDLE_IMG=${image} IMG=${img} CATALOG_IMG=${image}
- name: Deploy Container
env:
tag: ${{ env.tag }}
run: |
image=ghcr.io/converged-computing/oras-operator-${{ matrix.command }}:v${tag}
img=ghcr.io/converged-computing/oras-operator:v${tag}
make ${{ matrix.command }}-push BUNDLE_IMG=${image} IMG=${img} CATALOG_IMG=${image}
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
go-version: ^1.19
- name: Set tag
run: |
echo "Tag for release is ${{ inputs.release_tag }}"
echo "tag=${{ inputs.release_tag }}" >> ${GITHUB_ENV}
- name: Build release manifests
env:
tag: ${{ env.tag }}
run: |
make build-config-arm ARMIMG=ghcr.io/converged-computing/oras-operator:${tag}-arm
make build-config IMG=ghcr.io/converged-computing/oras-operator:v${tag}
- name: Release oras Operator
uses: softprops/action-gh-release@v1
with:
name: ORAS Operator Release v${{ env.tag }}
tag_name: ${{ env.tag }}
generate_release_notes: true
files: |
examples/dist/oras-operator-arm.yaml
examples/dist/oras-operator.yaml
env:
GITHUB_REPOSITORY: converged-computing/oras-operator
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# CHANGELOG

This is a manually generated log to track changes to the repository for each release.
Each section should include general headers such as **Implemented enhancements**
and **Merged pull requests**. Critical items to know are:

- renamed commands
- deprecated / removed commands
- changed defaults
- backward incompatible changes
- migration guidance
- changed behaviour

Releases coincide with versions released as tags on Github.

## [0.0.x](https://github.com/converged-computing/oras-operator/tree/main) (0.0.x)
- Skeleton release (0.0.0)
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ $(LOCALBIN):
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest
HELMIFY ?= $(LOCALBIN)/helmify

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
Expand Down Expand Up @@ -250,5 +251,5 @@ helm: manifests kustomize helmify
# go run hack/addons-gen/main.go docs/_static/data/addons.json

.PHONY: pre-push
pre-push: generate # build-config-arm build-config docs-data
pre-push: generate build-config-arm build-config # docs-data
git status
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ Deploy an ORAS registry (cache for workflow or experiment artifacts) as a servic

## TODO:

- test out setup with scripts, merge when basics are working
- create docs and automated builds for containers
- watch job (and then edit template) insteaed of pod (or make a variable, better?)
- watch job (and then edit template) instead of pod (or make a variable, better?)
- test with a simple dag (maybe snakemake kueue executor)
- multiple pods for registry and using secret / shared storage use case

Expand Down
23 changes: 23 additions & 0 deletions chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
21 changes: 21 additions & 0 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v2
name: chart
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.1.0"
Loading

0 comments on commit 8f8cb82

Please sign in to comment.