-
Notifications
You must be signed in to change notification settings - Fork 7
118 lines (115 loc) · 5.53 KB
/
main.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
name: Automated testing
# Currently we run in two situations:
on:
# Whenever someone pushes to a branch or tag in our repo
push:
branches:
- "*"
# Whenever a pull request is opened, reopened or gets new commits.
pull_request:
# This implies that for every push to a local branch in our repo for which a
# pull request is open this runs twice. But it's important to ensure that pull
# requests get tested even if their branch comes from a fork.
jobs:
# The l3build job contains the actual work. We misuse the matrix mechanism to
# create three jobs which only differ in minimal elements.
l3build:
runs-on: ${{(matrix.platform == 'Linux' && 'ubuntu-22.04') || (matrix.platform == 'Windows' && 'windows-2022') || (matrix.platform == 'macOS' && 'macos-13')}}
strategy:
matrix:
# include indicates that we want to set explicitly these combinations
# and don't want full matrix testing.
# "name" is just to make the output more readable.
# "l3build_cmd" is the actual command to run
# "artifact_name" is which artifact might get generated by this step.
# IMPORTANT: artifact_name == "Documentation" is used as a trigger to
# generate the artifact from PDF files and not the build directory and
# to generate the artifact when the run is successful, not when it fails.
kind: [test]
platform: [Linux, Windows, macOS]
include:
- kind: doc
platform: Linux
- name: "Test suite"
l3build_cmd: l3build check -q -H --show-log-on-error
artifact_name: testfiles
- name: "Documentation"
l3build_cmd: l3build doc -q -H
artifact_name: Documentation
name: "${{ format('{0} - {1}', matrix.kind == 'doc' && 'Documentation' || 'Test suite', matrix.platform) }}"
steps:
# Boilerplate
- name: Checkout repository
uses: actions/checkout@v4
# We need docutils for our documentation
- if: ${{ matrix.kind == 'doc' }}
run: sudo apt-get update && sudo apt-get install python3-docutils
- name: Install TeX Live
uses: zauguin/install-texlive@v3
with:
# The list of packages to install is in a separate file under .github/tl_packages
# to allow reuse.
package_file: .github/tl_packages
cache_version: 0
- name: Run l3build
run: ${{ format('l3build {0} -q -H', matrix.kind == 'doc' && 'doc' || 'check --show-log-on-error') }}
# Now we create the artifacts: There are two cases where this happens.
# 1. If we failed running tests
- name: Archive failed test output
if: ${{ matrix.kind == 'test' && always() }}
uses: zauguin/l3build-failure-artifacts@v1
with:
name: testfiles-${{ matrix.platform }}
# Decide how long to keep the test output artifact:
retention-days: 3
# 2. If we succeed building documentation
- name: Archive documentation
if: ${{ matrix.kind == 'doc' && success() }}
uses: actions/upload-artifact@v4
with:
name: Documentation
path: "**/*.pdf"
# Decide how long to keep the test output artifact:
retention-days: 21
# GitHub automatically informs the initiator of any action about the result, but
# we additionally want to keep the latex-commits mailing list informed about
# test failures.
notifiy:
name: Send notifications
runs-on: ubuntu-20.04
# Run after the `l3build` job in order to be able to react to it's output.
needs: l3build
# Only run if the tests failed, we don't want to get notifications for every run.
# We don't want information for pull requests since for pull requests from local
# branches we already send notifications when the branch test fails and pull requests
# from forks can't access the username and password secrets required to send mails.
if: ${{ failure() && github.event_name != 'pull_request' }}
steps:
- name: Send mail
# The explicit commit hash ensures that this can't be used by dawidd6 as a
# backdoor to execute arbitrary code during our runs.
uses: dawidd6/action-send-mail@4226df7daafa6fc901a43789c49bf7ab309066e7
with:
# Currently using my (Marcel's) mail server for sending mails.
server_address: typesetting.eu
server_port: 587
# These values can be changed in the repository settings.
username: ${{secrets.MAIL_USERNAME}}
password: ${{secrets.MAIL_PASSWORD}}
# If we want to send notifications to additional addresses, at them here as
# a comma separated list.
# The name is arbitrary, but if you want to change the address you need to
# coordinate it with the administrator of the mail server to allow the account
# to send from the mail address.
from: LaTeX CI <[email protected]>
priority: high
# Determine the subject and body of the mail.
subject: "Test failed: ${{github.repository}} (${{github.ref}})"
body: |
Test failure for ${{github.repository}}
-------------------------------------------------------------
On branch: ${{github.ref}} (${{github.sha}})
Initiated by: ${{github.actor}}
Commit URL: https://github.com/${{github.repository}}/commit/${{github.sha}}
More information: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}