-
-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (71 loc) · 2.98 KB
/
Copy pathtest.yml
File metadata and controls
82 lines (71 loc) · 2.98 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
name: test
on:
push:
branches: [main]
pull_request:
# Weekly drift check against the latest nightly. Advisory only -- it runs on
# main, so a failure never blocks a PR; it tells us the language moved under a
# frozen repo. See the install step for how the two modes differ.
schedule:
- cron: "12 13 * * 1"
workflow_dispatch:
env:
# The released Mojo this repo is known to build and pass on. CI installs
# exactly this for pushes and PRs, so upstream churn cannot turn a green repo
# red without a commit. Bump it when the weekly drift check goes green on a
# newer one, or after fixing whatever it caught.
MOJO_VERSION: "1.0.0"
jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install Mojo
run: |
uv venv
if [ "${{ github.event_name }}" = "schedule" ]; then
echo "::notice::Drift check: installing the LATEST nightly, ignoring the $MOJO_VERSION pin"
uv pip install mojo \
--index https://whl.modular.com/nightly/simple/ \
--prerelease allow
else
uv pip install "mojo==$MOJO_VERSION"
fi
.venv/bin/mojo --version
- name: Format check
run: |
.venv/bin/mojo format src/ test/ examples/ bench/
git diff --exit-code || (echo "::error::Run 'pixi run fmt' — sources are not mojo-format clean" && exit 1)
- name: Tests
run: .venv/bin/mojo run -I src test/test_diff.mojo
- name: Report nightly drift
if: failure() && github.event_name == 'schedule'
env:
GH_TOKEN: ${{ github.token }}
run: |
title="Mojo nightly drift: tests fail against the latest nightly"
installed=$(.venv/bin/mojo --version 2>/dev/null || echo "unknown")
# Heredoc, not a quoted string: a multi-line shell string would keep
# this block's indentation and markdown would render the body as code.
body=$(cat <<EOF
The weekly drift check failed against the latest Mojo nightly.
CI is pinned to $MOJO_VERSION and stays green, so no PR is blocked -- but
the latest nightly ($installed) no longer builds this repo.
Run: $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
Fix the breakage, then bump MOJO_VERSION in .github/workflows/test.yml
and .github/workflows/docs.yaml to the release that passes.
EOF
)
existing=$(gh issue list --repo "$GITHUB_REPOSITORY" --state open \
--search "$title in:title" --json number --jq '.[0].number // empty')
if [ -n "$existing" ]; then
gh issue comment "$existing" --repo "$GITHUB_REPOSITORY" --body "$body"
else
gh issue create --repo "$GITHUB_REPOSITORY" --title "$title" --body "$body"
fi