-
Notifications
You must be signed in to change notification settings - Fork 1.2k
178 lines (156 loc) · 6.58 KB
/
ci.yaml
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
168
169
170
171
172
173
174
175
176
177
178
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Format reference: https://docs.github.com/en/actions/reference
name: Compiler CI
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# Daily at 12pm UTC
- cron: '0 12 * * *'
permissions:
contents: read
env:
VERSION_NODEJS: '16.16.0'
UNSYMLINK_DIR: bazel-bin-unsymlink
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobs
jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Setup Java
# https://github.com/marketplace/actions/setup-java-jdk
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '11'
java-package: jdk
architecture: x64
# Clone closure-compiler repo from the commit under test into current directory.
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v4
# https://github.com/bazelbuild/setup-bazelisk
- uses: bazelbuild/setup-bazelisk@v2
- name: Build and Test
run: bazelisk test //:all
- name: Unsymlink Bazel Artifacts
# upload-artifact doesn't support paths with symlinks
run: |
mkdir -p ${{ env.UNSYMLINK_DIR }}
cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/compiler_uberjar_deploy.jar
cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/*_bundle.jar
# Share the following files with other jobs in this workflow. They can be grabbed using ID
# `unshaded_compiler`. This is made possible by uploading the files to GitHub controlled
# storage.
- name: Share Unshaded Compiler
# https://github.com/marketplace/actions/upload-a-build-artifact
uses: actions/upload-artifact@v4
with:
name: unshaded_compiler
path: ${{ env.UNSYMLINK_DIR }}/compiler_uberjar_deploy.jar
if-no-files-found: error
# If this build will be uploadaded as a SNAPSHOT, share the Sonatype bundles with the other
# jobs in this workflow. They can be grabbed using ID `snapshot_bundles`. This is made
# possible by uploading the files to GitHub controlled storage.
- name: Share Snapshot Bundles
# https://github.com/marketplace/actions/upload-a-build-artifact
if: ${{ github.event_name == 'schedule' }}
uses: actions/upload-artifact@v4
with:
name: snapshot_bundles
path: ${{ env.UNSYMLINK_DIR }}/*_bundle.jar
if-no-files-found: error
test-closure-compiler-npm:
name: Make Sure closure-compiler-npm is Compatible with this Compiler Build
runs-on: ubuntu-latest
needs:
- build-and-test
steps:
- name: Setup Node.js
# https://github.com/marketplace/actions/setup-node-js-environment
uses: actions/setup-node@v4
with:
node-version: ${{ env.VERSION_NODEJS }}
# Clone closure-compiler-npm repo from master into the current directory.
- name: Checkout Current closure-compiler-npm Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v4
with:
repository: google/closure-compiler-npm
ref: master
# Clone closure-compiler repo from the commit under test into the npm repo compiler
# submodule
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v4
with:
path: compiler
# Grab the compiler binary that was shared from `build-and-test` and put the file into
# ./compiler/bazel-bin.
- name: Grab Unshaded Compiler
# https://github.com/marketplace/actions/download-a-build-artifact
uses: actions/download-artifact@v4
with:
name: unshaded_compiler
# Put the binary where bazel would have put it.
path: compiler/bazel-bin
- name: Test closure-compiler-npm
run: compiler/.github/ci_support/test_closure-compiler-npm.sh compiler/bazel-bin/compiler_uberjar_deploy.jar
deploy-snapshots:
name: Deploy Snapshot Bundles to Sonatype
runs-on: ubuntu-latest
# Disable daily snapshot deployments. This will be later replaced with lower cadence releases.
if: false
needs:
- build-and-test
- test-closure-compiler-npm
steps:
# This also installs Maven, which is being used to do the SNAPSHOT deployment.
# TODO(nickreid): Delete this if we can find/write an upload tool other than Maven.
- name: Setup Java
# https://github.com/marketplace/actions/setup-java-jdk
uses: actions/setup-java@v4
with:
distribution: zulu
java-version: '11'
java-package: jdk
architecture: x64
# Clone closure-compiler repo from the commit under test into current directory.
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.VERSION_NODEJS }}
# Grab the SNAPSHOT bundles shared from `build-and-test` and put the file into ./bazel-bin.
- name: Grab Snapshot Bundles
uses: actions/download-artifact@v4
with:
name: snapshot_bundles
# Make it seem like files were generated by bazel
path: bazel-bin
# Upload the build from this commit to Sonatype for users who want to depend on the
# compiler at head. SNAPSHOTs are transient unversioned builds stored in a seperate
# artifact repo than versioned releases. This system is a purely Maven concept.
- name: Deploy Snapshot Bundles to Sonatype
run: .github/ci_support/deploy_sonatype_snapshot_bundles.js
env:
SONATYPE_USERNAME: closure-compiler
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}