-
Notifications
You must be signed in to change notification settings - Fork 9
143 lines (123 loc) · 3.97 KB
/
tests-and-docker-images.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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/cache@v2.1.7
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/cache@v2.1.7
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:
- id: lower-repo
shell: pwsh
run: |
"::set-output name=repository::$($env:GITHUB_REPOSITORY.ToLowerInvariant())"
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@v1.14.1
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/${{ steps.lower-repo.outputs.repository }}/${{ 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/${{ steps.lower-repo.outputs.repository }}/${{ matrix.image }}:latest
build-args: |
COMPILED_DATE=${{ env.COMPILED_DATE }}
VERSION=${{ env.VERSION }}
push: true