-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,261 additions
and
28 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:enhancement | ||
gha/ci: Execute smoke tests on GHA/CI | ||
``` |
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,35 +1,109 @@ | ||
name: Build & Push images | ||
|
||
on: workflow_dispatch | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
workflow_call: | ||
inputs: | ||
image_tag: | ||
required: true | ||
type: string | ||
# push: | ||
# branches: | ||
# - 'main' | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
production-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Checkout - set env | ||
run: echo "IMAGE_TAG=$(make version)" >> $GITHUB_ENV | ||
- | ||
name: Set up QEMU | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- | ||
name: Set up Docker Buildx | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- | ||
name: Login to Docker Hub | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v5 | ||
- name: Build and push release version | ||
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | ||
if: ${{ github.event_name != 'pull_request' && github.event_name != 'workflow_call' && github.event_name != 'workflow_dispatch' }} | ||
with: | ||
context: . | ||
file: production.dockerfile | ||
push: true | ||
tags: | | ||
${{ vars.DOCKERHUB_SK8L_UI_IMAGE_NAME }}:latest | ||
${{ vars.DOCKERHUB_SK8L_UI_IMAGE_NAME }}:${{ env.IMAGE_TAG }} | ||
${{ vars.DOCKERHUB_SK8L_UI_IMAGE_NAME }}:latestx | ||
${{ vars.DOCKERHUB_SK8L_UI_IMAGE_NAME }}:x-${{ env.IMAGE_TAG }} | ||
sk8l-ui-dev-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- name: Checkout - set env | ||
run: echo "IMAGE_TAG=$(make version)" >> $GITHUB_ENV | ||
- 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 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push dev version | ||
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | ||
if: ${{ github.event_name == 'workflow_call' && inputs.image_tag || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' }} | ||
with: | ||
context: . | ||
file: Dockerfile | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
push: true | ||
tags: | | ||
${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev | ||
${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev-${{ github.event.pull_request.head.ref }} | ||
${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:dev-${{ github.event.pull_request.number }} | ||
sk8l-ui-test-image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
- name: Checkout - set env | ||
run: echo "IMAGE_TAG=$(make version)" >> $GITHUB_ENV | ||
- 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 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push test version | ||
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | ||
if: ${{ github.event_name == 'workflow_call' && inputs.image_tag || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request' }} | ||
with: | ||
context: . | ||
file: Dockerfile.test | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
push: true | ||
tags: | | ||
${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:ui-test | ||
${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:ui-test-${{ github.event.pull_request.head.ref }} | ||
${{ vars.GHCR_SK8L_UI_IMAGE_NAME }}:ui-test-${{ github.event.pull_request.number }} |
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,99 @@ | ||
name: k8s-rwkld | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
pull_request_number: | ||
required: true | ||
type: number | ||
image_tag: | ||
required: true | ||
type: string | ||
kind_version: | ||
required: true | ||
type: string | ||
k8s_version: | ||
required: true | ||
type: string | ||
k8s_image: | ||
required: true | ||
type: string | ||
jobs: | ||
k8s-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 | ||
with: | ||
fetch-depth: 0 | ||
submodules: recursive | ||
# - name: Set up Go ${{ env.GO_VERSION }} | ||
# uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 | ||
# with: | ||
# go-version: ${{ env.GO_VERSION }} | ||
# check-latest: false | ||
# cache: false | ||
# id: go | ||
# - name: Update config files with dev docker image tag | ||
# if: | ||
# run: | | ||
# pr_image_tag=${{ inputs.image_tag }} | ||
# current_version=$(awk -F'"' '/\.Values\.sk8lApi\.imageTag/ {print $2}' charts/sk8l/templates/deployment.yaml) | ||
# sed -i.bak -E "s/.Values.sk8lApi.imageTag \| default \"$current_version\"/.Values.sk8lApi.imageTag | default \"$pr_image_tag\"/" charts/sk8l/templates/deployment.yaml | ||
# cp charts/sk8l/values.yaml charts/sk8l/values.yaml.bak | ||
# yq e -i ".sk8lApi.imageTag = \"$current_version\"" charts/sk8l/values.yaml | ||
# set +e | ||
# echo "after" | ||
# diff -C3 charts/sk8l/templates/deployment.yaml.bak charts/sk8l/templates/deployment.yaml | ||
# diff -C3 charts/sk8l/values.yaml.bak charts/sk8l/values.yaml | ||
# diff_status=$? | ||
# set -e | ||
# if [ $diff_status -eq 0 ]; then | ||
# echo "No differences found between the files." | ||
# exit 1 | ||
# fi | ||
- name: Get testdata | ||
run: | ||
curl -o testdata/sk8l-kind.yml https://raw.githubusercontent.com/danroux/sk8l-api/main/testdata/sk8l-kind.yml | ||
- name: Setup Kubernetes cluster ${{ inputs.kind_version }}/${{ inputs.k8s_version }} | ||
uses: engineerd/setup-kind@v0.5.0 | ||
with: | ||
name: sk8l | ||
version: ${{ inputs.kind_version }} | ||
image: ${{ inputs.k8s_image }} | ||
config: testdata/sk8l-kind.yaml | ||
- name: Test connection | ||
run: | | ||
kubectl cluster-info > /dev/null | ||
kubectl describe node > /dev/null | ||
- name: Install Helm | ||
uses: azure/setup-helm@v4.1.0 | ||
with: | ||
version: 'v3.13.3' | ||
- name: Setup certs | ||
run: | | ||
make setup-certs > /dev/null | ||
- name: Install Chart | ||
run: | | ||
make install-chart-ci > /dev/null | ||
- name: smoke tests | ||
id: smoke_tests | ||
run: | | ||
kubectl apply -f https://raw.githubusercontent.com/danroux/sk8l-api/main/testdata/sk8l-cronjobs.yml -n sk8l > /dev/null | ||
kubectl wait -n sk8l --for=condition=ready pod -l app.kubernetes.io/pod=sk8l-ui --timeout=300s | ||
sleep 60 | ||
kubectl apply -f testdata/cypress-job.yml -n sk8l | ||
kubectl wait --for=condition=complete job.batch/cypress-job -n sk8l --timeout=600s | ||
- name: /metrics smoke tests error output | ||
if: ${{ failure() && steps.metrics_smoke_tests.conclusion == 'failure' }} | ||
run: | | ||
echo "----------------------------" | ||
kubectl get pods -n sk8l | ||
kubectl get cronjobs -n sk8l | ||
echo "----------------------------" | ||
cat current_state.txt | ||
echo "----------------------------" | ||
cat expected_output.txt | ||
echo "----------------------------" | ||
cat job_output.txt | ||
exit 1 |
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,36 @@ | ||
name: k8s | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
env: | ||
GO_VERSION: "1.22.2" | ||
|
||
permissions: | ||
packages: write | ||
|
||
jobs: | ||
docker-img: | ||
name: Build Docker image dev-${{ github.event.pull_request.number }} | ||
uses: ./.github/workflows/docker.yml | ||
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} | ||
with: | ||
image_tag: dev-${{ github.event.pull_request.number }} | ||
secrets: inherit | ||
k8s-tests: | ||
name: k8s ${{ matrix.k8s.version }}/pr#${{ github.event.pull_request.number }} tests | ||
needs: [docker-img] | ||
strategy: | ||
matrix: | ||
k8s: | ||
- image: "kindest/node:v1.29.2@sha256:51a1434a5397193442f0be2a297b488b6c919ce8a3931be0ce822606ea5ca245" | ||
version: v1.29.2 | ||
kind: | ||
- version: "v0.22.0" | ||
uses: ./.github/workflows/k8s-test.yml | ||
with: | ||
image_tag: dev-${{ github.event.pull_request.number }} | ||
pull_request_number: ${{ github.event.pull_request.number }} | ||
kind_version: ${{ matrix.kind.version }} | ||
k8s_version: ${{ matrix.k8s.version }} | ||
k8s_image: ${{ matrix.k8s.image }} |
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
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,12 @@ | ||
FROM ghcr.io/danroux/sk8l-ui:dev AS release | ||
|
||
FROM cypress/included:13.7.3 | ||
LABEL org.opencontainers.image.source=https://github.com/danroux/sk8l-ui | ||
LABEL org.opencontainers.image.description="sk8l-ui ui-test image" | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
# USER 1001 | ||
|
||
# RUN chown -R 1001:1001 /var/cache | ||
# COPY --chown=1001:1001 --from=release /usr/app ./e2e | ||
COPY --from=release /usr/app ./e2e |
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
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,24 @@ | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
clientCertificates: [ | ||
{ | ||
url: 'https://sk8l-ui', | ||
ca: ['testdata/sk8l-certs/ca-cert.pem'], | ||
certs: [ | ||
{ | ||
cert: 'testdata/sk8l-certs/server-cert.pem', | ||
key: 'testdata/sk8l-certs/server-key.pem', | ||
}, | ||
], | ||
} | ||
], | ||
e2e: { | ||
baseUrl: 'https://sk8l-ui:8001', | ||
supportFile: false, | ||
video: false, | ||
specPattern: [ | ||
"cypress/**/*.spec.js" | ||
] | ||
} | ||
}) |
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,9 @@ | ||
describe('Home Test', () => { | ||
it('visits the homepage', () => { | ||
cy.visit('https://sk8l-ui:8001/') | ||
// cy.contains('It looks like no cronjobs exist for this namespace') | ||
cy.contains('sk8l / download-report-files') | ||
cy.contains('sk8l / process-csv-files') | ||
cy.contains('sk8l / process-videos') | ||
}) | ||
}) |
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
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
Oops, something went wrong.