Skip to content

Commit 4c17f19

Browse files
authored
Chore/fix magefile running test (#1492)
* chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> * chore: validate magefile goals Signed-off-by: chenk <[email protected]> --------- Signed-off-by: chenk <[email protected]>
1 parent a370cc5 commit 4c17f19

File tree

5 files changed

+127
-81
lines changed

5 files changed

+127
-81
lines changed

.github/workflows/build.yaml

+22-6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ jobs:
4747
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
4848
restore-keys: |
4949
${{ runner.os }}-go-
50+
- name: Install tools
51+
uses: aquaproj/[email protected]
52+
with:
53+
aqua_version: v1.25.0
5054
- name: Verify Go code
5155
uses: golangci/[email protected]
5256
with:
@@ -57,11 +61,11 @@ jobs:
5761
- name: Verify YAML code
5862
uses: ibiqlik/action-yamllint@v3
5963
- name: Vendor Go modules
60-
run: go mod vendor
64+
run: go mod tidy
6165
- name: Verify all generated
62-
run: make verify-generated
66+
run: mage generate:verify
6367
- name: Verify Generated Helm docs
64-
run: make verify-generated-helm-docs
68+
run: mage generate:verifydocs
6569
tests:
6670
name: Run tests
6771
runs-on: ubuntu-latest
@@ -78,8 +82,12 @@ jobs:
7882
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
7983
restore-keys: |
8084
${{ runner.os }}-go-
85+
- name: Install tools
86+
uses: aquaproj/[email protected]
87+
with:
88+
aqua_version: v1.25.0
8189
- name: Run unit tests
82-
run: make test
90+
run: mage test:unit
8391
- name: Upload code coverage
8492
uses: codecov/codecov-action@v3
8593
with:
@@ -103,8 +111,12 @@ jobs:
103111
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
104112
restore-keys: |
105113
${{ runner.os }}-go-
114+
- name: Install tools
115+
uses: aquaproj/[email protected]
116+
with:
117+
aqua_version: v1.25.0
106118
- name: Run envtest
107-
run: make envtest
119+
run: mage test:envtest
108120
- name: Upload code coverage
109121
uses: codecov/codecov-action@v3
110122
with:
@@ -128,6 +140,10 @@ jobs:
128140
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
129141
restore-keys: |
130142
${{ runner.os }}-go-
143+
- name: Install tools
144+
uses: aquaproj/[email protected]
145+
with:
146+
aqua_version: v1.25.0
131147
- name: Setup Kubernetes cluster (KIND)
132148
uses: engineerd/[email protected]
133149
with:
@@ -141,7 +157,7 @@ jobs:
141157
- name: Run integration tests
142158
run: |
143159
kubectl create -k deploy/static
144-
make itests-trivy-operator
160+
mage test:integration
145161
env:
146162
KUBECONFIG: /home/runner/.kube/config
147163
OPERATOR_NAMESPACE: trivy-system

.github/workflows/release.yaml

+10-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ jobs:
3232
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
3333
restore-keys: |
3434
${{ runner.os }}-go-
35+
- name: Install tools
36+
uses: aquaproj/[email protected]
37+
with:
38+
aqua_version: v1.25.0
3539
- name: Run unit tests
36-
run: make test
40+
run: mage test:unit
3741
itest-trivy-operator:
3842
name: Run integration tests / Trivy Operator
3943
needs:
@@ -53,6 +57,10 @@ jobs:
5357
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
5458
restore-keys: |
5559
${{ runner.os }}-go-
60+
- name: Install tools
61+
uses: aquaproj/[email protected]
62+
with:
63+
aqua_version: v1.25.0
5664
- name: Setup Kubernetes cluster (KIND)
5765
uses: engineerd/[email protected]
5866
with:
@@ -66,7 +74,7 @@ jobs:
6674
- name: Run integration tests
6775
run: |
6876
kubectl create -k deploy/static
69-
make itests-trivy-operator
77+
mage test:integration
7078
env:
7179
KUBECONFIG: /home/runner/.kube/config
7280
OPERATOR_NAMESPACE: trivy-system

CONTRIBUTING.md

+15-14
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ Each commit message doesn't have to follow conventions as long as it is clear an
7373
Note: Some of our tests performs integration testing by starting a local
7474
control plane using
7575
[envtest](https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/envtest).
76-
If you only run test using the Makefile
77-
(`m̀ake test`), no additional installation is required. But if you want to
76+
If you only run test using the Magefile
77+
(`mage test:unit`), no additional installation is required. But if you want to
7878
run some of these integration tests using `go test` or from your IDE, you'll
7979
have to
8080
[install kubebuiler-tools](https://book.kubebuilder.io/reference/envtest.html#installation).
81+
[install magefile](https://magefile.org) or use `go run mage.go <goal>`
8182

8283
## Build Binaries
8384

@@ -88,21 +89,21 @@ have to
8889
To build all Trivy-operator binary, run:
8990

9091
```
91-
make
92+
mage build:all
9293
```
9394

9495
This uses the `go build` command and builds binaries in the `./bin` directory.
9596

9697
To build all Trivy-operator binary into Docker images, run:
9798

9899
```
99-
make docker-build
100+
mage build:docker
100101
```
101102

102103
To load Docker images into your KIND cluster, run:
103104

104105
```
105-
kind load docker-image aquasecurity/trivy-operator:dev
106+
mage build:kindloadimages
106107
```
107108

108109
## Testing
@@ -116,7 +117,7 @@ collaborators, more coarse grained integration tests might be required.
116117
To run all tests with code coverage enabled, run:
117118

118119
```
119-
make test
120+
mage test:unit
120121
```
121122

122123
To open the test coverage report in your web browser, run:
@@ -130,7 +131,7 @@ go tool cover -html=coverage.txt
130131
The operator envtest spin us partial k8s components (api-server, etcd) and test controllers for reousce, workload, ttl, rbac and more
131132

132133
```
133-
make envtest
134+
mage test:envtest
134135
```
135136

136137
### Run Integration Tests
@@ -155,7 +156,7 @@ To run the integration tests for Trivy-operator Operator and view the coverage r
155156
OPERATOR_NAMESPACE=trivy-system \
156157
OPERATOR_TARGET_NAMESPACES=default \
157158
OPERATOR_LOG_DEV_MODE=true \
158-
make itests-trivy-operator
159+
mage test:integration
159160
go tool cover -html=itest/trivy-operator/coverage.txt
160161
```
161162

@@ -217,11 +218,11 @@ We currently generate:
217218
- Mandatory DeepCopy functions for a Go struct representing a CRD
218219

219220
This means that you should not try to modify any of these files directly, but instead change
220-
the code and code markers. Our Makefile contains a target to ensure that all generated files
221+
the code and code markers. Our MageFile contains a target to ensure that all generated files
221222
are up-to-date: So after doing modifications in code, affecting CRDs/ClusterRole, you should
222-
run `make generate-all` to regenerate everything.
223+
run `mage generate:all` to regenerate everything.
223224

224-
Our CI will verify that all generated is up-to-date by running `make verify-generated`.
225+
Our CI will verify that all generated is up-to-date by running `mage generate:verify`.
225226

226227
Any change to the CRD structs, including nested structs, will probably modify the CRD.
227228
This is also true for Go docs, as field/type doc becomes descriptions in CRDs.
@@ -248,7 +249,7 @@ basic development workflow. For other install modes see [Operator Multitenancy w
248249
1. Build the operator binary into the Docker image and load it from your host into KIND cluster nodes:
249250

250251
```
251-
make docker-build-trivy-operator && kind load docker-image aquasecurity/trivy-operator:dev
252+
mage build:docker && kind load docker-image aquasecurity/trivy-operator:dev
252253
```
253254

254255
2. Create the `trivy-operator` Deployment in the `trivy-system` namespace to run the operator's container:
@@ -318,7 +319,7 @@ To avoid maintaining resources in multiple places, we have a created a script
318319
to (re)generate the static resources from the Helm chart.
319320

320321
So if modifying the operator resources, please do so by modifying the Helm
321-
chart, then run `make manifests` to ensure the static
322+
chart, then run `mage generate:manifests` to ensure the static
322323
resources are up-to-date.
323324

324325
## Update helm docs
@@ -328,7 +329,7 @@ Since some prefer to not use Helm, we also provide helm config documentation to
328329
install the operator.
329330

330331
So if modifying the operator helm params, please do so by modifying the Helm
331-
chart, then run `make generate-helm-docs` to ensure the helm docs are up-to-date.
332+
chart, then run `mage generate:docs` to ensure the helm docs are up-to-date.
332333

333334
## Operator Lifecycle Manager (OLM)
334335

aqua.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# aqua - Declarative CLI Version Manager
3+
# https://aquaproj.github.io/
4+
registries:
5+
- type: standard
6+
ref: v3.157.0 # renovate: depName=aquaproj/aqua-registry
7+
packages:
8+
- name: magefile/[email protected]

0 commit comments

Comments
 (0)