-
Notifications
You must be signed in to change notification settings - Fork 2
181 lines (150 loc) · 6.09 KB
/
Copy pathtest-fossa.yml
File metadata and controls
181 lines (150 loc) · 6.09 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: FOSSA Scan Tests
on:
# Due to security constraints we cannot run the workflow on PRs due to missing secrets on PRs from forks
push:
branches:
- "main"
- "release-*"
permissions:
contents: read
actions: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-fossa-maven-scan:
name: Test FOSSA Maven Scan
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout github-actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.sha }}
- name: Checkout strimzi/drain-cleaner
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: strimzi/drain-cleaner
ref: 1.6.1
path: drain-cleaner
- name: Copy drain-cleaner project to workspace root
run: rsync -a --exclude='.git' --exclude='.github' drain-cleaner/ ./
- name: Setup Java and Maven
uses: ./.github/actions/dependencies/setup-java
- name: Install yq
uses: ./.github/actions/dependencies/install-yq
- name: Restore Maven cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: Build Maven project
shell: bash
run: mvn -B -DskipTests -Dmaven.javadoc.skip=true clean install
- name: Run FOSSA Maven scan
uses: ./.github/actions/security/fossa-maven-scan
with:
# Keep false to avoid running policy tests during testing
fossaTest: "true"
scanName: test-maven-drain-cleaner
branch: "1.6.1"
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}
# Test workflow loads image artifacts from test-integrations workflow.
# To avoid additional image build, the scan check will wait until integration workflow store the artifacts
wait-for-container-artifact:
name: Wait for Container Artifact
runs-on: ubuntu-latest
timeout-minutes: 90
outputs:
run-id: ${{ steps.find-build.outputs.run_id }}
steps:
- name: Wait for container artifact
id: find-build
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
INPUT_SHA: ${{ github.sha }}
ARTIFACT_NAME: "containers-drain-cleaner-amd64.tar"
MAX_WAIT_MINUTES: "20"
with:
script: |
const {owner, repo} = context.repo;
const workflowName = 'test-integrations.yml';
const sha = process.env.INPUT_SHA;
const artifactName = process.env.ARTIFACT_NAME;
const maxWaitMinutes = parseInt(process.env.MAX_WAIT_MINUTES);
const maxWaitSeconds = maxWaitMinutes * 60;
const startTime = Date.now();
core.info(`Waiting for artifact '${artifactName}' from commit ${sha}`);
async function findArtifact() {
const runs = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id: workflowName,
head_sha: sha,
per_page: 1
});
const run = runs.data.workflow_runs[0];
if (!run) return null;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: run.id
});
const artifact = artifacts.data.artifacts.find(a => a.name === artifactName);
if (artifact) {
return { runId: run.id, artifactId: artifact.id };
}
if (run.status === 'completed') {
core.setFailed(`Integration tests completed (${run.conclusion}) but artifact '${artifactName}' not found`);
core.setFailed(`Run: ${context.serverUrl}/${owner}/${repo}/actions/runs/${run.id}`);
return 'failed';
}
return null;
}
while (true) {
const elapsed = Math.floor((Date.now() - startTime) / 1000);
if (elapsed >= maxWaitSeconds) {
core.setFailed(`Timeout: Artifact '${artifactName}' not found after ${maxWaitMinutes} minutes`);
return;
}
const result = await findArtifact();
if (result === 'failed') return;
if (result) {
core.setOutput('run_id', result.runId.toString());
core.info(`Artifact '${artifactName}' found in run #${result.runId}`);
return;
}
core.info(`Artifact not available yet... (${elapsed}s elapsed, max: ${maxWaitSeconds}s)`);
await new Promise(resolve => setTimeout(resolve, 30000));
}
test-fossa-container-scan-drain-cleaner:
name: Test FOSSA Container Scan (drain-cleaner)
needs: wait-for-container-artifact
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout github-actions
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install Docker
uses: ./.github/actions/dependencies/install-docker
- name: Download container archive
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: containers-drain-cleaner-amd64.tar
run-id: ${{ needs.wait-for-container-artifact.outputs.run-id }}
github-token: ${{ github.token }}
- name: Untar container archive
run: tar -xvf containers-drain-cleaner-amd64.tar
- name: Run FOSSA container scan
uses: ./.github/actions/security/fossa-container-scan
with:
imageFile: drain-cleaner-container-amd64.tar.gz
image: drain-cleaner-amd64
scanName: test-container-drain-cleaner-amd64
fossaTest: "true"
branch: "1.6.1"
env:
FOSSA_API_KEY: ${{ secrets.FOSSA_API_KEY }}