forked from mockito/mockito
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (83 loc) · 3.42 KB
/
ci.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
#
# CI build that assembles artifacts and runs tests.
# If validation is successful this workflow releases from the main dev branch.
#
# - skipping CI: add [skip ci] to the commit message
# - skipping release: add [skip release] to the commit message
#
name: CI
on:
push:
branches: ['release/3.x']
tags: [v*]
pull_request:
branches: ['**']
jobs:
#
# Main build job
#
build:
runs-on: ubuntu-latest
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
# Definition of the build matrix
strategy:
matrix:
java: [8, 11, 15]
mock-maker: ['mock-maker-default', 'mock-maker-inline']
# All build steps
# SINGLE-MATRIX-JOB means that the step does not need to be executed on every job in the matrix
steps:
- name: 1. Check out code
uses: actions/[email protected] # https://github.com/actions/checkout
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
- name: 2. Set up Java ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: ${{ matrix.java }}
- name: 3. Validate Gradle wrapper
if: matrix.java == 8 && matrix.mock-maker == 'mock-maker-default' # SINGLE-MATRIX-JOB
uses: gradle/[email protected] # https://github.com/gradle/wrapper-validation-action
- name: 4. Build and check reproducibility of artifacts (single job only)
if: matrix.java == 8 && matrix.mock-maker == 'mock-maker-default' # SINGLE-MATRIX-JOB
run: ./check_reproducibility.sh
- name: 5. Spotless check (single job only). Run './gradlew spotlessApply' locally if this job fails.
if: matrix.java == 11 && matrix.mock-maker == 'mock-maker-default' # SINGLE-MATRIX-JOB
run: ./gradlew spotlessCheck
- name: 6. Build on Java ${{ matrix.java }} with ${{ matrix.mock-maker }}
run: ./gradlew build idea --scan
env:
MOCK_MAKER: ${{ matrix.mock-maker }}
- name: 7. Upload coverage report
run: |
./gradlew coverageReport -s --scan && cp build/reports/jacoco/mockitoCoverage/mockitoCoverage.xml jacoco.xml || echo "Code coverage failed"
bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
#
# Release job, only for pushes to the main development branch
#
release:
runs-on: ubuntu-latest
needs: [build] # build job must pass before we can release
if: github.event_name == 'push'
&& (github.ref == 'refs/heads/release/3.x' || startsWith(github.ref, 'refs/tags/v'))
&& github.repository == 'mockito/mockito'
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
steps:
- name: Check out code
uses: actions/[email protected] # https://github.com/actions/checkout
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
- name: Set up Java 8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 8
- name: Build and release
run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository releaseSummary
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
NEXUS_TOKEN_USER: ${{secrets.NEXUS_TOKEN_USER}}
NEXUS_TOKEN_PWD: ${{secrets.NEXUS_TOKEN_PWD}}
PGP_KEY: ${{secrets.PGP_KEY}}
PGP_PWD: ${{secrets.PGP_PWD}}