This repository has been archived by the owner on Sep 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
126 lines (115 loc) · 4.3 KB
/
build.yml
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
# Copyright 2010-2021 by Sebastian Thomschke and contributors.
# SPDX-License-Identifier: EPL-2.0
#
# Author: Sebastian Thomschke, https://sebthom.de/
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- '.github/*.yml'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
additional_maven_args:
description: 'Additional Maven Args'
required: false
default: ''
jobs:
build:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
- java: 8
may_create_release: ${{ github.ref == 'refs/heads/main' }}
experimental: false
- java: 11
may_create_release: false
experimental: true
steps:
- name: Git Checkout
uses: actions/checkout@v2 #https://github.com/actions/checkout
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v2 #https://github.com/actions/setup-java
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
# reusing CDS archives of the same JVM randomly fails in GitHub Actions with
# "An error has occurred while processing the shared archive file. shared class paths mismatch"
#- name: Calculate Java version checksum
# id: java-version-checksum
# run: |
# echo "::set-output name=md5sum::$(java -version 2>&1 | md5sum | cut -f1 -d" ")"
#- name: Cache Java CDS archive
# uses: actions/cache@v2
# with:
# path: |
# ~/.xshare/${{ steps.java-version-checksum.outputs.md5sum }}
# key: ${{ runner.os }}-xshare-${{ steps.java-version-checksum.outputs.md5sum }}
- name: "Cache: Local Maven Repository"
uses: actions/cache@v2
with:
path: |
~/.m2/repository
!~/.m2/repository/net/sf/oval
key: ${{ runner.os }}-mvnrepo-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-mvnrepo-
- name: "Cache: Maven Binaries"
uses: actions/cache@v2
with:
path: |
~/.m2/bin
key: ${{ runner.os }}-mvnbin-${{ hashFiles('.ci/build.sh') }}
- name: Test with Maven
id: maven-test
if: ${{ !matrix.may_create_release }}
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_API_KEY: ${{ github.token }}
JAVA_VERSION: ${{ matrix.java }}
MAY_CREATE_RELEASE: false
run: |
bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }}
- name: Build with Maven
id: maven-build
if: matrix.may_create_release
env:
DEPLOY_SNAPSHOTS_TO_GITHUB_BRANCH: true
GITHUB_USER: ${{ github.actor }}
GITHUB_API_KEY: ${{ secrets.GH_API_TOKEN }}
JAVA_VERSION: ${{ matrix.java }}
MAY_CREATE_RELEASE: ${{ matrix.may_create_release }}
SIGN_KEY: ${{ secrets.GPG_SIGN_KEY }}
SIGN_KEY_PASS: ${{ secrets.GPG_SIGN_KEY_PWD }}
SONATYPE_OSSRH_USER: ${{ secrets.SONATYPE_OSSRH_USER }}
SONATYPE_OSSRH_USER_TOKEN: ${{ secrets.SONATYPE_OSSRH_USER_TOKEN }}
run: |
set -eu
# https://github.community/t/github-actions-bot-email-address/17204
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
bash .ci/build.sh ${{ github.event.inputs.additional_maven_args }}
if find . -path "*/target/site/jacoco/jacoco.xml" | grep -q .; then
echo '::set-output name=has_jacoco_results::true'
fi
- name: Publish test coverage to codeclimate.com
uses: paambaati/codeclimate-action@v2.7.5 # https://github.com/paambaati/codeclimate-action
if: matrix.may_create_release && steps.maven-build.outputs.has_jacoco_results
env:
CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TEST_REPORTER_ID }}
JACOCO_SOURCE_PATH: "${{ github.workspace }}/src/main/java"
with:
coverageLocations: |
${{ github.workspace }}/target/site/jacoco/jacoco.xml:jacoco
${{ github.workspace }}/target/site/jacoco-it/jacoco.xml:jacoco