-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adopt skaffold and just, test skeleton
Signed-off-by: Ievgenii Shepeliuk <[email protected]>
- Loading branch information
1 parent
98a69d4
commit 44bc6eb
Showing
8 changed files
with
130 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,24 +14,20 @@ on: | |
branches: | ||
- "master" | ||
|
||
env: | ||
IMAGE: openpolicyagent/kube-mgmt | ||
|
||
jobs: | ||
build_job: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Build Docker image and Helm chart | ||
run: | | ||
docker build --build-arg VERSION=${{ env.VERSION }} \ | ||
--build-arg COMMIT=${{ env.GITHUB_SHA }} \ | ||
-t ${{ env.IMAGE }}:${{ env.VERSION }} . | ||
helm lint charts/opa | ||
helm package charts/opa \ | ||
--version ${{ env.VERSION }} \ | ||
--app-version ${{ env.VERSION }} | ||
env: | ||
VERSION: 0.0.0 # nothing ispublished, version can be set to fake value | ||
- uses: actions/checkout@v2 | ||
- uses: volesen/[email protected] | ||
with: | ||
version: 'v1.33.0' | ||
- uses: extractions/setup-just@v1 | ||
- run: just test | ||
- uses: rinx/[email protected] | ||
with: | ||
skipClusterCreation: true | ||
- run: | | ||
just k3d | ||
just build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,16 +5,16 @@ on: | |
tags: | ||
- '[0-9]+.[0-9]+.[0-9]+' | ||
|
||
env: | ||
IMAGE: openpolicyagent/kube-mgmt | ||
|
||
jobs: | ||
docker_job: | ||
name: Docker image | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- uses: actions/checkout@v2 | ||
- uses: volesen/[email protected] | ||
with: | ||
version: 'v1.33.0' | ||
- uses: extractions/setup-just@v1 | ||
- name: Calculate release version | ||
id: theVersion | ||
run: echo "::set-output name=theVersion::$(echo ${GITHUB_REF##*/})" | ||
|
@@ -23,23 +23,9 @@ jobs: | |
with: | ||
username: ${{ secrets.DOCKER_USER }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
- name: Build Docker image and Helm chart | ||
run: | | ||
docker build --build-arg VERSION=${{ env.VERSION }} \ | ||
--build-arg COMMIT=${{ env.GITHUB_SHA }} \ | ||
-t ${{ env.IMAGE }}:${{ env.VERSION }} . | ||
helm package charts/opa \ | ||
--version ${{ env.VERSION }} \ | ||
--app-version ${{ env.VERSION }} | ||
env: | ||
VERSION: ${{ steps.theVersion.outputs.theVersion }} | ||
- name: Publish Docker image | ||
- name: Build docker image | ||
run: | | ||
docker push ${{ env.IMAGE }}:${{ env.VERSION }} | ||
docker tag ${{ env.IMAGE }}:${{ env.VERSION }} ${{ env.IMAGE }}:latest | ||
docker push ${{ env.IMAGE }}:latest | ||
env: | ||
VERSION: ${{ steps.theVersion.outputs.theVersion }} | ||
just VERSION=${{ steps.theVersion.outputs.theVersion }} build-latest | ||
- name: Upload Helm artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
|
@@ -51,8 +37,7 @@ jobs: | |
runs-on: ubuntu-latest | ||
needs: docker_job | ||
steps: | ||
- name: Checkout gh-pages | ||
uses: actions/checkout@v2 | ||
- uses: actions/checkout@v2 | ||
with: | ||
ref: gh-pages | ||
- name: Download artifact from build job | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
bin | ||
.go | ||
*.tgz | ||
skaffold.json | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
export COMMIT := `git rev-parse --short HEAD` | ||
export VERSION := "0.0.0-" + COMMIT | ||
|
||
default: | ||
@just --list | ||
|
||
@skaffold-ctx: | ||
skaffold config set default-repo localhost:5000 -k k3d-kube-mgmt | ||
|
||
# build docker image and pack helm chart | ||
@build: skaffold-ctx | ||
skaffold build -t {{VERSION}} --file-output=skaffold.json | ||
helm package charts/opa --version {{VERSION}} --app-version {{VERSION}} | ||
|
||
build-latest: build | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
LATEST="$(jq -r .builds[0].imageName skaffold.json):latest" | ||
CURRENT="$(jq -r .builds[0].tag skaffold.json)" | ||
docker tag $CURRENT $LATEST | ||
docker push $LATEST | ||
@test-helm: | ||
./test/linter/test.sh | ||
|
||
@test-e2e: | ||
./test/e2e/test.sh | ||
|
||
# run all tests | ||
test: test-helm test-e2e | ||
|
||
# recreate local k8s cluster with k3d | ||
@k3d: && skaffold-ctx | ||
k3d cluster delete kube-mgmt || true | ||
k3d cluster create --config ./test/e2e/k3d.yaml | ||
|
||
# @up: skaffold-ctx build | ||
# skaffold run | ||
# | ||
# @down: | ||
# skaffold delete || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: skaffold/v2beta19 | ||
kind: Config | ||
metadata: | ||
name: kube-mgmt | ||
build: | ||
artifacts: | ||
- image: openpolicyagent/kube-mgmt | ||
context: . | ||
docker: | ||
buildArgs: | ||
VERSION: "{{.VERSION}}" | ||
COMMIT: "{{.COMMIT}}" | ||
local: | ||
push: true | ||
useBuildkit: true | ||
profiles: | ||
- name: local | ||
activation: | ||
- kubeContext: k3d-kube-mgmt | ||
deploy: | ||
helm: | ||
releases: | ||
- name: kube-mgmt | ||
chartPath: charts/opa | ||
wait: true | ||
upgradeOnChange: false | ||
skipBuildDependencies: true | ||
artifactOverrides: | ||
image: openpolicyagent/kube-mgmt | ||
imageStrategy: | ||
helm: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: k3d.io/v1alpha3 | ||
kind: Simple | ||
name: kube-mgmt | ||
servers: 1 | ||
agents: 0 | ||
registries: | ||
create: | ||
name: kube-mgmt-registry | ||
host: "0.0.0.0" | ||
hostPort: "5000" | ||
config: | | ||
mirrors: | ||
"localhost:5000": | ||
endpoint: | ||
- http://kube-mgmt-registry:5000 | ||
options: | ||
k3d: | ||
disableLoadbalancer: true | ||
k3s: | ||
extraArgs: | ||
- arg: "--disable=servicelb,traefik,local-storage,metrics-server" | ||
nodeFilters: ["all"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
echo "E2E tests version=${VERSION}, sha=${COMMIT}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
helm lint charts/opa --strict | ||
if [ $? -ne 0 ]; then | ||
exit 1 | ||
fi | ||
|
||
echo "==================================================================================" | ||
echo " LINT PASSED" | ||
echo "==================================================================================" |