Repository navigation
78 lines (72 loc) · 2.6 KB
/
Copy pathjava.yml
File metadata and controls
78 lines (72 loc) · 2.6 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
name: Java
on:
pull_request:
paths:
- "**/*.java"
- "**/*.gradle"
push:
branches:
- main
workflow_dispatch:
jobs:
build:
name: Check if tests compile cleanly with starter sources
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 1.17
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
with:
java-version: 17
distribution: "temurin"
- name: Check if tests compile cleanly with starter sources
run: ./gradlew compileStarterTestJava --continue
working-directory: exercises
lint:
name: Lint Java files using Checkstyle
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up JDK 1.17
uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93
with:
java-version: 17
distribution: "temurin"
- name: Run checkstyle
run: ./gradlew check --exclude-task test --continue
working-directory: exercises
test:
name: Test all exercises using java-test-runner
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Test all exercises using java-test-runner
run: bin/test-with-test-runner
- name: Create test summary
uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
with:
script: |
const fs = require('node:fs/promises')
const globber = await glob.create('exercises/**/build/results.json')
for await (const file of globber.globGenerator()) {
const slug = file.split('/').slice(-3, -2)[0]
const data = await fs.readFile(file, 'utf8')
const results = JSON.parse(data)
if (results.status === 'error') {
core.error(results.message, {title: `[${slug}] Error while running tests`});
continue;
}
for (const test of results.tests) {
switch (test.status) {
case "pass":
core.info(`[${slug}] Test passed: ${test.name}`);
break;
case "fail":
core.warning(test.message, {title: `[${slug}] Test failed: ${test.name}`});
break;
case "error":
core.warning(test.message, {title: `[${slug}] Test errored: ${test.name}`});
break;
}
}
}