2022-04-26 03:33:15 +08:00
|
|
|
name: Bazel Build and Test
|
|
|
|
|
|
|
|
on:
|
2023-11-23 10:00:39 +08:00
|
|
|
# TODO: Fix bazel build after US holidays of 2023-Nov-23 and re-enable.
|
|
|
|
# push:
|
|
|
|
# branches: [ main ]
|
2022-08-10 04:28:21 +08:00
|
|
|
workflow_dispatch:
|
2022-04-26 03:33:15 +08:00
|
|
|
|
2022-08-13 08:38:48 +08:00
|
|
|
# Ensure that only a single job or workflow using the same
|
|
|
|
# concurrency group will run at a time. This would cancel
|
|
|
|
# any in-progress jobs in the same github workflow and github
|
|
|
|
# ref (e.g. refs/heads/main or refs/pull/<pr_number>/merge).
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
|
2022-04-26 03:33:15 +08:00
|
|
|
jobs:
|
2022-08-12 07:35:15 +08:00
|
|
|
ubuntu-build:
|
|
|
|
name: ubuntu-x86_64
|
CI script improvements (#1547)
* ci: update versions of external actions
Node.js 12 actions are deprecated and will eventually go away, so this
patch bumps the old actions to their latest versions that use Node.js
16.
* ci: replace deprecated action with bash commands
The llvm/actions/install-ninja action uses Node.js 12, which is
deprecated. Since that action is not updated to work with Node.js 16,
this patch replaces that action with equivalent bash commands to install
Ninja.
* ci: use smaller ccache artifacts to reduce evictions
Over time, our ccache sizes have grown quite large (some as large as
1.3 GB), which results in us routinely exceeding GitHub's limits, thus
triggering frequent cache evictions. As a result, cache downloads and
uploads take unnecessary long, in addition to fewer cache entries being
available.
Based on experiments on a clean cache state, it appears that we need
less than 300 MB of (compressed) ccache artifacts for each build type.
Anything larger than that will accrue changes from the past that aren't
needed.
To alleviate the cache burden, this patch sets the maximum ccache size
to be 300 MB. This change should not affect the success or failure of
our builds. I will monitor the build times to check whether this change
causes any performance degradation.
* ci: use consistent platform identifiers
Prior to this patch, some of our builds ran on `ubuntu-latest`, while
some others ran on `ubuntu-20.04` and others ran on `ubuntu-22.04`, with
similar situations for macOS and windows. This patch instead sets all
Linux builds to run on `ubuntu-latest`, all macOS builds to run on
`macos-latest`, and all Windows builds to run on `windows-latest`, to
make debugging future CI failures a little easier.
2022-11-03 10:37:01 +08:00
|
|
|
runs-on: ubuntu-latest
|
2022-08-12 07:35:15 +08:00
|
|
|
|
2022-04-26 03:33:15 +08:00
|
|
|
steps:
|
2023-04-07 01:36:30 +08:00
|
|
|
- name: Prepare workspace
|
|
|
|
run: |
|
|
|
|
# Clear the workspace directory so that we don't run into errors about
|
|
|
|
# existing lock files.
|
|
|
|
sudo rm -rf $GITHUB_WORKSPACE/*
|
|
|
|
|
2022-08-12 07:35:15 +08:00
|
|
|
- name: Checkout torch-mlir
|
2022-08-18 03:46:17 +08:00
|
|
|
uses: actions/checkout@v3
|
2023-04-07 01:36:30 +08:00
|
|
|
with:
|
|
|
|
submodules: 'true'
|
2022-08-12 07:35:15 +08:00
|
|
|
|
2022-11-17 03:59:33 +08:00
|
|
|
# Continually update cache even if there's a "hit" during
|
|
|
|
# restore to avoid the cache going stale over time
|
|
|
|
# https://github.com/actions/cache/blob/main/workarounds.md#update-a-cache
|
2022-08-18 03:46:17 +08:00
|
|
|
- name: Setup cache for bazel
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: ~/.cache/bazel
|
2022-11-16 10:48:31 +08:00
|
|
|
key: torch_mlir-bazel-build-cache-${{ runner.os }}-${{ github.sha }}
|
|
|
|
restore-keys: |
|
|
|
|
torch_mlir-bazel-build-cache-${{ runner.os }}
|
2022-08-18 03:46:17 +08:00
|
|
|
|
2022-08-18 08:04:50 +08:00
|
|
|
# Change bazel cache directory to root ownership
|
|
|
|
# to allow writing to it from within the docker container.
|
|
|
|
# If no cache hits, this directory is not present
|
|
|
|
# so don't run chown (will error otherwise).
|
2022-08-18 03:46:17 +08:00
|
|
|
- name: Set bazel cache permissions
|
|
|
|
run: |
|
2022-08-18 08:04:50 +08:00
|
|
|
if [ -d "${HOME}/.cache/bazel" ]; then
|
|
|
|
sudo chown -R root:root "${HOME}/.cache/bazel"
|
|
|
|
fi
|
2022-08-18 03:46:17 +08:00
|
|
|
|
|
|
|
- name: Build docker image
|
|
|
|
run: |
|
|
|
|
docker build -f utils/bazel/docker/Dockerfile \
|
|
|
|
-t torch-mlir:ci \
|
|
|
|
.
|
|
|
|
|
2023-06-29 23:45:35 +08:00
|
|
|
- name: Verify buildifier was run (bazel lint)
|
2022-08-18 03:46:17 +08:00
|
|
|
run: |
|
|
|
|
docker run --rm \
|
|
|
|
-v "$(pwd)":"/opt/src/torch-mlir" \
|
|
|
|
-v "${HOME}/.cache/bazel":"/root/.cache/bazel" \
|
|
|
|
torch-mlir:ci \
|
2023-06-29 23:45:35 +08:00
|
|
|
bazel run @torch-mlir//:buildifier
|
|
|
|
if [ -n "$(git status --porcelain)" ]; then
|
|
|
|
echo "Please 'bazel run @torch-mlir//:buildifier' and commit changes."
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-08-18 03:46:17 +08:00
|
|
|
|
2023-06-29 23:45:35 +08:00
|
|
|
- name: Bazel build torch-mlir
|
2022-11-17 03:59:33 +08:00
|
|
|
run: |
|
|
|
|
docker run --rm \
|
|
|
|
-v "$(pwd)":"/opt/src/torch-mlir" \
|
|
|
|
-v "${HOME}/.cache/bazel":"/root/.cache/bazel" \
|
|
|
|
torch-mlir:ci \
|
2023-06-29 23:45:35 +08:00
|
|
|
bazel build @torch-mlir//:torch-mlir-opt
|
2022-11-17 03:59:33 +08:00
|
|
|
|
2023-06-29 23:45:35 +08:00
|
|
|
- name: Bazel test torch-mlir (lit tests)
|
2022-12-09 07:56:57 +08:00
|
|
|
run: |
|
|
|
|
docker run --rm \
|
|
|
|
-v "$(pwd)":"/opt/src/torch-mlir" \
|
|
|
|
-v "${HOME}/.cache/bazel":"/root/.cache/bazel" \
|
|
|
|
torch-mlir:ci \
|
2023-06-29 23:45:35 +08:00
|
|
|
bazel test @torch-mlir//test/...
|
2022-12-09 07:56:57 +08:00
|
|
|
|
2022-08-18 08:04:50 +08:00
|
|
|
# Switch back bazel cache directory to user ownership
|
|
|
|
# to allow GHA post-cache step to save cache without
|
|
|
|
# permissions issue.
|
2022-08-18 03:46:17 +08:00
|
|
|
- name: Switch bazel cache permissions
|
2022-04-26 03:33:15 +08:00
|
|
|
run: |
|
2022-08-18 08:04:50 +08:00
|
|
|
if [ -d "${HOME}/.cache/bazel" ]; then
|
|
|
|
sudo chown -R "$USER":"$USER" "${HOME}/.cache/bazel"
|
|
|
|
fi
|
2022-08-12 07:35:15 +08:00
|
|
|
|
2022-04-26 03:33:15 +08:00
|
|
|
- name: Send mail
|
|
|
|
if: failure()
|
|
|
|
uses: dawidd6/action-send-mail@v3
|
|
|
|
with:
|
|
|
|
server_address: ${{ secrets.SMTP_SERVER }}
|
|
|
|
server_port: ${{ secrets.SMTP_PORT }}
|
|
|
|
username: ${{ secrets.SMTP_USERNAME }}
|
|
|
|
password: ${{ secrets.SMTP_PASSWORD }}
|
|
|
|
subject: GitHub Action Bazel Build and Test failed!
|
|
|
|
body: Bazel Build job failed! See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} for more information.
|
|
|
|
to: ${{ secrets.MAIL_RECEIVER }}
|
|
|
|
from: Torch-MLIR Bazel Build GitHub Actions
|