Skip to content

Merge pull request #146 from AKamyshnikova/bump-bootstrap-0.1.15 #374

Merge pull request #146 from AKamyshnikova/bump-bootstrap-0.1.15

Merge pull request #146 from AKamyshnikova/bump-bootstrap-0.1.15 #374

name: Test & publish Docker images
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
- trigger-integration
paths-ignore:
- 'website/**'
tags: ["*"]
env:
REGISTRY: ghcr.io
IMAGE: ${{ github.head_ref || github.ref_name }}
jobs:
not-missing-manifests:
runs-on: ubuntu-latest
if: ${{ github.ref_type == 'branch' }}
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
container: ghcr.io/cscetbon/casskop-build
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache vendor modules
uses: actions/[email protected]
env:
cache-name: casskop-vendor
with:
path: |
vendor
/go/pkg
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
- name: Download dependencies
run: go mod download
- name: Vendor dependencies
run: go mod vendor
- name: Validate operator-sdk Bundle
run: |
make bundle-validate
- name: Ensure there are no missing CRDs changes
run: |
[ "$(git ls-files -m | grep -cE 'zz_generated|crds')" -eq 0 ]
unit-tests:
runs-on: ubuntu-latest
container: ghcr.io/cscetbon/casskop-build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache vendor modules
uses: actions/[email protected]
env:
cache-name: casskop-vendor
with:
path: |
vendor
/go/pkg
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
${{ runner.os }}-
- name: Run unit Tests
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
env:
POD_NAME: test
KUBERNETES_CONFIG: config/test-kube-config.yaml
run: |
go mod vendor
go test -mod=vendor --cover --coverprofile=coverage.out `go list -mod=vendor ./... | grep -v e2e`
go tool cover -html=coverage.out -o coverage.html
docker-images:
runs-on: ubuntu-latest
permissions:
packages: write
needs: unit-tests
strategy:
matrix:
image: [casskop, multi-casskop]
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- run: |
echo "COMPILED_DATE=$(date -u '+%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
echo "VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ matrix.image }}/Dockerfile
tags: ghcr.io/cscetbon/${{ matrix.image }}:${{ env.IMAGE }}
build-args: |
COMPILED_DATE=${{ env.COMPILED_DATE }}
VERSION=${{ env.VERSION }}
push: ${{ env.IMAGE == 'master' || github.ref_type == 'tag' }}
- name: Tag Docker image as latest
if: ${{ github.ref_type == 'tag' }}
uses: docker/build-push-action@v4
with:
context: .
file: docker/${{ matrix.image }}/Dockerfile
tags: ghcr.io/cscetbon/${{ matrix.image }}:latest
build-args: |
COMPILED_DATE=${{ env.COMPILED_DATE }}
VERSION=${{ env.VERSION }}
push: true