-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (119 loc) · 4.08 KB
/
tests.yaml
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
name: Tests
on:
push:
branches:
- master
tags:
- "*"
pull_request:
schedule:
- cron: '0 5 * * *'
jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- name: Check style
run: make -C functionaltest-jenkins-plugin style
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Initialize CodeQL
if: github.event_name == 'push'
uses: github/codeql-action/init@v3
with:
languages: java, javascript
- name: Build with Maven
run: cd stackrox-container-image-scanner && ./mvnw -B verify package hpi:hpi cyclonedx:makeAggregateBom
- uses: actions/upload-artifact@v4
with:
name: stackrox-container-image-scanner.hpi
path: stackrox-container-image-scanner/target/stackrox-container-image-scanner.hpi
- uses: actions/upload-artifact@v4
with:
name: stackrox-container-image-scanner.jar
path: stackrox-container-image-scanner/target/stackrox-container-image-scanner.jar
- name: Perform CodeQL Analysis
if: github.event_name == 'push'
uses: github/codeql-action/analyze@v3
e2e:
if: github.event_name == 'push' || !github.event.pull_request.head.repo.fork
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Setup infractl
uses: stackrox/actions/infra/install-infractl@main
- uses: actions/checkout@v4
with:
repository: stackrox/stackrox
path: stackrox
- uses: docker/setup-buildx-action@v3
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'gradle'
- uses: actions/download-artifact@v4
with:
name: stackrox-container-image-scanner.hpi
path: jenkins
- uses: actions/download-artifact@v4
with:
name: stackrox-container-image-scanner.hpi
path: stackrox-container-image-scanner/target/
- name: Build jenkins image
uses: docker/build-push-action@v6
with:
tags: jenkins-test
context: jenkins
push: false
load: true
- name: Run jenkins in background
run: docker run -d --add-host host.docker.internal:host-gateway -p 8080:8080 jenkins-test
- name: Create GKE infra cluster
uses: stackrox/actions/infra/[email protected]
with:
token: ${{ secrets.INFRA_TOKEN }}
flavor: qa-demo
name: jenkins-plugin-${{ github.run_id }}
lifespan: 1h
args: main-image=quay.io/stackrox-io/main:latest
wait: "true"
no-slack: "true"
- name: Setup environment from cluster artifacts
env:
CLUSTER_NAME: jenkins-plugin-${{ github.run_id }}
INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }}
ARTIFACTS_DIR: ${{ runner.temp }}/gke-artifacts
run: |
# Fetch the artifacts for the GKE cluster.
infractl artifacts --download-dir=${ARTIFACTS_DIR} ${CLUSTER_NAME} >/dev/null
# Set both URL and admin password.
ROX_PASSWORD=$(cat ${ARTIFACTS_DIR}/admin-password)
ROX_ENDPOINT=$(cat ${ARTIFACTS_DIR}/url)
echo "::add-mask::$ROX_PASSWORD"
echo "::add-mask::$ROX_ENDPOINT"
echo "ROX_PASSWORD=$ROX_PASSWORD" >> $GITHUB_ENV
echo "ROX_ENDPOINT=$ROX_ENDPOINT" >> $GITHUB_ENV
- name: Run tests
run: |
echo $ROX_ENDPOINT
make -C functionaltest-jenkins-plugin test
- name: Teardown cluster
if: always()
env:
INFRA_TOKEN: ${{ secrets.INFRA_TOKEN }}
run: |
infractl delete jenkins-plugin-${{ github.run_id }} || echo "Failed to remove the infra cluster"