Compiler CI #5063
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 }} |