-
Notifications
You must be signed in to change notification settings - Fork 3
167 lines (164 loc) · 6.94 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
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
name: Build with Gradle
on:
workflow_dispatch:
inputs:
releaseVersion:
type: string
description: New version for the release. When empty release publishing skipped.
default: ''
required: true
push:
branches: [ 'main' ]
pull_request:
branches: [ 'main' ]
jobs:
build:
strategy:
matrix:
os: [ubuntu-24.04, windows-2022]
runs-on: ${{ matrix.os }}
permissions:
actions: write
contents: read
steps:
- name: Change Gradle user home
shell: bash
if: ${{ startsWith(matrix.os, 'windows') }}
run: |
GRADLE_USER_HOME=${RUNNER_TEMP}\.gradle
mkdir -p "${GRADLE_USER_HOME}"
echo "GRADLE_USER_HOME=${GRADLE_USER_HOME}" >> ${GITHUB_ENV}
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up JDK
uses: actions/setup-java@8df1039502a15bceb9433410b1a100fbe190c53b # v4.5.0
with:
java-version-file: '.java-version'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
- name: Bump version
if: github.event_name == 'workflow_dispatch' && github.event.inputs.releaseVersion != ''
run: |
./bumpVersion.sh "${RELEASE_VERSION}"
env:
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
- name: Publish Gradle Plugin to Maven Local
run: |
./gradlew :robolectric-extension-gradle-plugin:publishToMavenLocal --configure-on-demand
env:
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD }}'
- name: Build with Gradle Wrapper
run: |
./gradlew build koverXmlReport publish
env:
JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_USERNAME }}'
JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_MAVEN_PASSWORD }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD }}'
- name: Publish Gradle Plugin
run: |
./publishGradlePlugin.sh
env:
JUNIT5_ROBOLECTRIC_EXTENSION_GRADLE_PLUGIN_PORTAL_KEY: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GRADLE_PLUGIN_PORTAL_KEY }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GRADLE_PLUGIN_PORTAL_SECRET: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GRADLE_PLUGIN_PORTAL_SECRET }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_KEY }}'
JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD: '${{ secrets.JUNIT5_ROBOLECTRIC_EXTENSION_GPG_SIGNING_PASSWORD }}'
- name: Upload unit test report
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: ${{ always() && hashFiles('**/test-results/**/*.xml') != '' }}
with:
name: ${{ matrix.os }}-unit-test-report
path: |
${{ github.workspace }}/**/build/reports/tests
${{ github.workspace }}/**/build/test-results
retention-days: 5
- name: Upload coverage report
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: ${{ always() && hashFiles('build/reports/kover/report.xml') != '' }}
with:
name: ${{ matrix.os }}-kover-report
path: ${{ github.workspace }}/build/reports/kover/report.xml
retention-days: 5
release:
runs-on: ubuntu-24.04
permissions:
contents: write
needs:
- build
if: github.ref_name == github.event.repository.default_branch && github.event_name == 'workflow_dispatch' && github.event.inputs.releaseVersion != '' && !endsWith(github.event.inputs.releaseVersion, 'SNAPSHOT')
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.head_ref }}
- name: Create release
shell: bash
run: |
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
./tagRelease.sh "${RELEASE_VERSION}"
env:
GIT_USER_NAME: ${{ github.actor }}
GIT_USER_EMAIL: ${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com
RELEASE_VERSION: ${{ github.event.inputs.releaseVersion }}
junit:
strategy:
matrix:
os: [ ubuntu-24.04, windows-2022 ]
runs-on: ${{ matrix.os }}
needs:
- build
permissions:
actions: read
checks: write
contents: read
if: github.repository == 'apter-tech/junit5-robolectric-extension' && github.event_name == 'pull_request'
steps:
- name: Download unit test report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ matrix.os }}-unit-test-report
- name: Comment unit test report
if: ${{ hashFiles('**/test-results/**/*.xml') != '' }}
uses: mikepenz/action-junit-report@992d97d6eb2e5f3de985fbf9df6a04386874114d # v5.1.0
with:
report_paths: '**/test-results/**/*.xml'
check_name: Unit test report (${{ matrix.os }})
kover:
strategy:
matrix:
os: [ ubuntu-24.04, windows-2022 ]
runs-on: ${{ matrix.os }}
needs:
- build
permissions:
actions: read
checks: write
contents: read
pull-requests: write
if: github.repository == 'apter-tech/junit5-robolectric-extension' && github.event_name == 'pull_request'
steps:
- name: Download coverage report
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: ${{ matrix.os }}-kover-report
- name: Comment branch coverage report to PR
uses: mi-kas/kover-report@5f58465b6f395c8fa3adc2665e27250bad87de50 # v1.9
if: ${{ hashFiles('report.xml') != '' }}
with:
path: ${{ github.workspace }}/report.xml
title: Branch Coverage (${{ matrix.os }})
update-comment: true
min-coverage-overall: 60
min-coverage-changed-files: 70
coverage-counter-type: BRANCH
- name: Comment line coverage report to PR (${{ matrix.os }})
uses: mi-kas/kover-report@5f58465b6f395c8fa3adc2665e27250bad87de50 # v1.9
if: ${{ hashFiles('report.xml') != '' }}
with:
path: ${{ github.workspace }}/report.xml
title: Line Coverage (${{ matrix.os }})
update-comment: true
min-coverage-overall: 60
min-coverage-changed-files: 70
coverage-counter-type: LINE