servo/.github/workflows/mac.yml
Martin Robinson fdcbe613ac
Allow trigger try workfows using labels (#30383)
This change adds and alternate method for triggering try changes.
Instead of comments, changes are triggered via applying labels to pull
requests. The action will remove the label from the request and start
the requested jobs.

This will require creating at least a few labels:

 - T-full
 - T-linux-wpt-2013
 - T-linux-wpt-2020
 - T-macos
 - T-windows

More labels can be added as we support more configurations.

The good thing about this change is that try jobs against the actual
branch in the pull request instead of the master branch. This means
that changes to CI can be tested (unlike for comment processing).

One bit caveat with this change is that when adding multiple labels, a
CI job is triggered for each. Only one real build will run for each
label, but whether or more try jobs is triggered is a race condition.
The first CI job to successfully remove the label will actually trigger
the job. If the same job removes two compatible labels, then they can
share a build (for instance two types of WPT linux jobs). If not there
will be two. Note that this is at least as efficient as the current
behavior.
2023-10-23 11:57:36 +00:00

151 lines
4.7 KiB
YAML

name: Mac
on:
workflow_call:
inputs:
wpt-layout:
required: false
type: string
unit-tests:
required: false
default: false
type: boolean
upload:
required: false
default: false
type: boolean
github-release-id:
required: false
type: string
workflow_dispatch:
inputs:
wpt-layout:
required: false
type: choice
options: ["none", "2013", "2020", "all"]
unit-tests:
required: false
default: false
type: boolean
upload:
required: false
default: false
type: boolean
push:
branches: ["try-mac", "try-wpt-mac", "try-wpt-mac-2020"]
env:
RUST_BACKTRACE: 1
SHELL: /bin/bash
SCCACHE_GHA_ENABLED: "true"
RUSTC_WRAPPER: "sccache"
CCACHE: "sccache"
CARGO_INCREMENTAL: 0
jobs:
build:
name: Mac Build
runs-on: macos-13
steps:
- uses: actions/checkout@v3
if: github.event_name != 'issue_comment' && github.event_name != 'pull_request_target'
with:
fetch-depth: 2
# This is necessary to checkout the pull request if this run was triggered
# via an `issue_comment` action on a pull request.
- uses: actions/checkout@v3
if: github.event_name == 'issue_comment' || github.event_name == 'pull_request_target'
with:
ref: refs/pull/${{ github.event.issue.number || github.event.number }}/head
fetch-depth: 2
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Install taplo
uses: baptiste0928/cargo-install@v2
with:
crate: taplo-cli
locked: true
- name: Bootstrap
run: |
python3 -m pip install --upgrade pip virtualenv
python3 ./mach bootstrap
brew install gnu-tar
- name: Release build
run: |
python3 ./mach build --release
- name: Smoketest
run: python3 ./mach smoketest --release
- name: Script tests
run: ./mach test-scripts
- name: Unit tests
if: ${{ inputs.unit-tests || github.ref_name == 'try-mac' }}
timeout-minutes: 30 # https://github.com/servo/servo/issues/30275
run: python3 ./mach test-unit --release
- name: Package
run: python3 ./mach package --release
- name: Package smoketest
run: ./etc/ci/macos_package_smoketest.sh target/release/servo-tech-demo.dmg
- name: Rename build timing
run: cp -r target/cargo-timings target/cargo-timings-macos
- name: Archive build timing
uses: actions/upload-artifact@v3
with:
name: cargo-timings
# Using a wildcard here ensures that the archive includes the path.
path: target/cargo-timings-*
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: mac
path: target/release/servo-tech-demo.dmg
- name: Upload
if: ${{ inputs.upload }}
run: |
python3 ./mach upload-nightly mac --secret-from-environment \
--github-release-id ${{ inputs.github-release-id }}
env:
S3_UPLOAD_CREDENTIALS: ${{ secrets.S3_UPLOAD_CREDENTIALS }}
GITHUB_HOMEBREW_TOKEN: ${{ secrets.HOMEBREW_TOKEN }}
NIGHTLY_REPO_TOKEN: ${{ secrets.NIGHTLY_REPO_TOKEN }}
NIGHTLY_REPO: ${{ github.repository_owner }}/servo-nightly-builds
- name: Package binary
run: gtar -czf target.tar.gz target/release/servo target/release/*.dylib target/release/lib/*.dylib resources
- name: Archive binary
uses: actions/upload-artifact@v3
with:
name: release-binary-macos
path: target.tar.gz
wpt-2020:
if: ${{ github.ref_name == 'try-wpt-mac-2020' || inputs.wpt-layout == '2020' || inputs.wpt-layout == 'all' }}
name: Mac WPT Tests 2020
needs: ["build"]
uses: ./.github/workflows/mac-wpt.yml
with:
layout: "layout-2020"
wpt-2013:
if: ${{ github.ref_name == 'try-wpt-mac' || inputs.wpt-layout == '2013' || inputs.wpt-layout == 'all' }}
name: Mac WPT Tests 2013
needs: ["build"]
uses: ./.github/workflows/mac-wpt.yml
with:
layout: "layout-2013"
result:
name: Result
runs-on: ubuntu-latest
if: always()
# needs all build to detect cancellation
needs:
- "build"
- "wpt-2020"
- "wpt-2013"
steps:
- name: Mark the job as successful
run: exit 0
if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }}
- name: Mark the job as unsuccessful
run: exit 1
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')