112 lines
3.5 KiB
YAML
112 lines
3.5 KiB
YAML
name: e2e tests
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
concurrency:
|
|
group: e2e-tests=full-${{ github.head_ref || github.ref }}-${{ github.repository }}
|
|
cancel-in-progress: true
|
|
jobs:
|
|
push-docker:
|
|
env:
|
|
REPO: ttl.sh/elemental-operator-ci
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
chart_name: ${{ steps.chart.outputs.chart_name }}
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Export tag
|
|
id: export_tag
|
|
run: |
|
|
TAG=`git describe --abbrev=0 --tags 2>/dev/null || echo "v0.0.0"`
|
|
COMMITDATE=`date -d @$(git log -n1 --format="%at") "+%FT%TZ"`
|
|
echo "operator_tag=$TAG" >> $GITHUB_OUTPUT
|
|
echo "commit_date=$COMMITDATE" >> $GITHUB_OUTPUT
|
|
- name: Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v4.1.1
|
|
with:
|
|
images: |
|
|
${{ env.REPO }}
|
|
tags: |
|
|
type=sha,format=short,prefix=${{ steps.export_tag.outputs.operator_tag }}-
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2.2.1
|
|
- name: Build image
|
|
uses: docker/build-push-action@v3.2.0
|
|
with:
|
|
context: .
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
push: true
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
target: elemental-operator
|
|
build-args: |
|
|
TAG=${{ steps.export_tag.outputs.operator_tag }}
|
|
COMMITDATE=${{ steps.export_tag.outputs.commit_date }}
|
|
COMMIT=${{ github.sha }}
|
|
- name: Make chart
|
|
run: REPO=${{ env.REPO }} make chart
|
|
- name: Set chart output
|
|
id: chart
|
|
run: |
|
|
CHART=$(basename `find . -type f -name "elemental-operator*.tgz" -print`)
|
|
echo "chart_name=$CHART" >> $GITHUB_OUTPUT
|
|
- name: Upload chart
|
|
uses: actions/upload-artifact@v3.1.0
|
|
with:
|
|
name: chart
|
|
path: build/*.tgz
|
|
e2e-tests:
|
|
strategy:
|
|
matrix:
|
|
kubernetes: [ "v1.24.6", "v1.23.12"]
|
|
replicas: ["1"]
|
|
rancherVersion : ["2.6.9"]
|
|
runs-on: ubuntu-latest
|
|
needs: push-docker
|
|
name: k8s ${{ matrix.kubernetes }} - Rancher ${{ matrix.rancherVersion }} - ${{ matrix.replicas }} replicas
|
|
env:
|
|
CHART: ${{ github.workspace }}/build/${{ needs.push-docker.outputs.chart_name }}
|
|
KUBE_VERSION: ${{ matrix.kubernetes }}
|
|
OPERATOR_REPLICAS: ${{ matrix.replicas }}
|
|
RANCHER_VERSION: ${{ matrix.rancherVersion }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Download chart
|
|
uses: actions/download-artifact@v3.0.0
|
|
with:
|
|
name: chart
|
|
path: build
|
|
- name: Install Go
|
|
uses: actions/setup-go@v3
|
|
with:
|
|
go-version: 1.17.x
|
|
- uses: actions/cache@v3.0.11
|
|
with:
|
|
path: |
|
|
~/go/pkg/mod
|
|
~/.cache/go-build
|
|
key: ${{ runner.os }}-test-go-${{ hashFiles('**/go.sum') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-test-go-${{ hashFiles('**/go.sum') }}
|
|
- uses: engineerd/setup-kind@v0.5.0
|
|
with:
|
|
version: "v0.16.0"
|
|
skipClusterCreation: "true"
|
|
- name: e2e tests
|
|
run: make e2e-tests
|
|
- name: Archive artifacts
|
|
if: always()
|
|
uses: actions/upload-artifact@v3.1.0
|
|
with:
|
|
name: ci-artifacts
|
|
path: _artifacts
|
|
if-no-files-found: ignore
|