forked from opentripplanner/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (124 loc) · 5.6 KB
/
cibuild.yml
File metadata and controls
143 lines (124 loc) · 5.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
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
name: OTP CI Build
# On [push, pull_request] causes double-builds when creating PRs.
# But triggering on push only will miss pull requests from outside authors.
# The push event's ref is the name of the pushed branch;
# The pull_request event's branch name is the merge target branch.
on:
push:
branches:
- master
- dev-1.x
- dev-2.x
pull_request:
branches:
- master
- dev-1.x
- dev-2.x
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
# Starting in v2.2 checkout action fetches all tags when fetch-depth=0, for auto-versioning.
- uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
# Java setup step completes very fast, no need to run in a preconfigured docker container
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
# on windows there are frequent failures caused by page files being too small
# https://github.com/actions/virtual-environments/issues/785
- name: Configure Windows Pagefile
if: matrix.os == 'windows-latest'
uses: al-cheb/configure-pagefile-action@v1.3
- name: Prepare coverage agent, build and test
run: mvn --batch-mode --update-snapshots jacoco:prepare-agent verify jacoco:report -P prettierCheck
- name: Send coverage data to codecov.io
if: github.repository_owner == 'opentripplanner' && matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3.1.1
with:
files: target/site/jacoco/jacoco.xml
- name: Deploy to Github Package Registry
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev-1.x' || github.ref == 'refs/heads/dev-2.x') && matrix.os == 'ubuntu-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --batch-mode deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierCheck -P deployGitHub
docs:
if: github.repository_owner == 'opentripplanner'
runs-on: ubuntu-latest
env:
REMOTE: docs
LOCAL_BRANCH: local-pages
REMOTE_BRANCH: main
TOKEN: ${{ secrets.CHANGELOG_TOKEN }}
MASTER_BRANCH_VERSION: 2.3.0
steps:
- uses: actions/checkout@v3.1.0
# this is necessary so that the correct credentials are put into the git configuration
# when we push to dev-2.x and push the HTML to the git repo
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master')
with:
token: ${{ secrets.CHANGELOG_TOKEN }}
- uses: actions/checkout@v3.1.0
# for a simple PR where we don't push, we don't need any credentials
if: github.event_name == 'pull_request'
- name: Install Python dependencies
run: pip install -r docs/requirements.txt
- name: Build documentation
if: github.event_name == 'pull_request'
run: mkdocs build
- name: Deploy docs to Github pages
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master')
run: |
git config --global user.name 'OTP Bot'
git config --global user.email 'bot@opentripplanner.org'
# mike, the versioning plugin for mkdocs, expects there to be a local branch to push to so
# we are cloning one here and commit to it
# mike has support for specifing the origin but then it tries to rebase the _local_ gh-pages
# branch onto the remote which fails. that's the reason for this git hackery.
git remote add $REMOTE https://$TOKEN@github.com/opentripplanner/docs.git
git fetch $REMOTE $REMOTE_BRANCH:$LOCAL_BRANCH
# prefix is the root folder where to deploy the HTML, we use 'en' to emulate the URL
# structure of readthedocs
if [ ${{ github.ref }} = 'refs/heads/master' ];
then
mike deploy --branch $LOCAL_BRANCH --prefix en --title=$MASTER_BRANCH_VERSION --update-aliases v$MASTER_BRANCH_VERSION latest
else
mike deploy --branch $LOCAL_BRANCH --prefix en dev-2.x
fi
git push $REMOTE $LOCAL_BRANCH:$REMOTE_BRANCH
container-image:
if: github.repository_owner == 'opentripplanner' && github.event_name == 'push' && github.ref == 'refs/heads/dev-2.x'
runs-on: ubuntu-latest
needs: build
env:
CONTAINER_REPO: docker.io/opentripplanner/opentripplanner
CONTAINER_REGISTRY_USER: otpbot
CONTAINER_REGISTRY_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
steps:
- uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: maven
- name: Build container image with Jib, push to Dockerhub
run: |
# we give the container three tags
# - "latest"
# - the git SHA1
# - a string like "2.3_2022-12-12T21-38"
version_with_snapshot=`mvn -q help:evaluate -Dexpression=project.version -q -DforceStdout`
version=${version_with_snapshot/-SNAPSHOT/}
image_date=`date +%Y-%m-%dT%H-%M`
image_version="${version}_${image_date}"
mvn --batch-mode compile com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,${{ github.sha }},$image_version