summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yml
blob: d6d574600a05645ed21d2ff9ff8df0098c1c171b (plain)
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
name: Build

on:
  pull_request:
    branches: [master]
  push:
    branches: [master]

jobs:
  build:
    name: Build (Java ${{ matrix.java }} - ${{ matrix.os }})
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        java: [11, 17, 18]
        include:
          - os: windows-latest
            java: 18
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@v1
      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          distribution: 'zulu'
          java-version: ${{ matrix.java }}
      - name: Build with Gradle
        uses: gradle/gradle-build-action@v2
        with:
          arguments: build codeCoverageReport
          # Only write to the cache for builds on the 'main' branch.
          # Builds on other branches will only read existing entries from the cache.
          cache-read-only: ${{ github.ref != 'refs/heads/main' }}
      - name: Publish report
        if: always()
        uses: mikepenz/action-junit-report@v3.3.3
        with:
          check_name: test (Java ${{ matrix.java }})
          report_paths: '**/build/test-results/test/TEST-*.xml'
          github_token: ${{ secrets.GITHUB_TOKEN }}
      - name: Upload artifacts
        if: always()
        continue-on-error: true # See https://github.com/actions/upload-artifact/issues/270
        uses: actions/upload-artifact@v3
        with:
          name: reports-${{ matrix.os }}-jdk${{ matrix.java }}
          path: |
            ./**/build/reports/**/*
            ./**/build/test-results/**/*
          retention-days: 5
      - name: Upload code coverage
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          files: ./build/reports/jacoco/codeCoverageReport/codeCoverageReport.xml
  build-docker:
      name: Build Docker Images
      runs-on: ubuntu-latest
      steps:
        - name: Checkout repository
          uses: actions/checkout@v3
        - name: Build UI
          uses: docker/build-push-action@v3
          with:
            context: opendc-web/opendc-web-ui
            file: opendc-web/opendc-web-ui/Dockerfile
        - name: Build Web Server
          uses: docker/build-push-action@v3
          with:
            file: opendc-web/opendc-web-server/Dockerfile
        - name: Build Runner
          uses: docker/build-push-action@v3
          with:
            file: opendc-web/opendc-web-runner/Dockerfile