Repository navigation
146 lines (133 loc) · 5.97 KB
/
Copy pathci.yml
File metadata and controls
146 lines (133 loc) · 5.97 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
# Runs the shared testbox harness (via `rake`) for every language listed
# in the matrix below - that list *is* the "which languages are tested
# in CI" tag: add a language to CI by adding a matrix entry here, drop
# one by removing it. There's deliberately no separate manifest file to
# keep in sync with this - the matrix is the single source of truth.
#
# `rake` only actually fails this job on a failing test because of the
# at_exit hook at the bottom of testbox/Script.rb - without it, Ruby
# exits 0 regardless of how many individual test comparisons came back
# false, and this workflow would report green no matter what broke.
on:
push:
pull_request:
jobs:
test:
name: ${{ matrix.name }}
runs-on: ubuntu-latest
strategy:
# One matrix entry failing shouldn't cancel the others still
# running - each language's result should be visible on its own.
fail-fast: false
matrix:
include:
- name: python3
dir: lessons/gen_scripts/python3
- name: ruby
dir: lessons/gen_scripts/ruby
- name: perl
dir: lessons/gen_scripts/perl
- name: bash
dir: lessons/shell_scripts/bash
# Script.rb's `command` runs posix/ specifically under dash,
# not plain "sh" (which ubuntu-latest's default /bin/sh
# symlink already points at, but relying on that symlink
# rather than naming dash directly is exactly the
# "bashisms" risk lessons/shell_scripts/posix/README.md warns
# about) - see the native_unix? gate in Script.rb.
- name: posix
dir: lessons/shell_scripts/posix
# :ps1 lessons run fine under POSIX pwsh (Script.rb's `command`
# already handles this - see native_unix?), so this doesn't
# need windows-latest.
- name: powershell
dir: lessons/win_scripts/powershell
# g++/make are already on ubuntu-latest, so cpp needs no extra
# setup step below - only go and rust do.
- name: cpp
dir: lessons/compiled_lang/cpp
- name: go
dir: lessons/compiled_lang/go
- name: rust
dir: lessons/compiled_lang/rust
- name: java
dir: lessons/compiled_lang/java
- name: cs
dir: lessons/compiled_lang/cs
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Ruby (for rake, and for the ruby/ lesson itself)
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
# bash's c2/c3/k0 lessons shell out to `bc` for floating-point math
# (bash itself has no float support) - installed only if missing,
# since some runner images already carry it and some don't (found
# the hard way testing this workflow locally with `act`, whose
# minimal runner image doesn't).
- name: Ensure bc is available
if: matrix.name == 'bash' || matrix.name == 'posix'
run: command -v bc || (sudo apt-get update -qq && sudo apt-get install -y bc)
- name: Ensure dash is available
if: matrix.name == 'posix'
run: command -v dash || (sudo apt-get update -qq && sudo apt-get install -y dash)
- name: Ensure Switch.pm is available
if: matrix.name == 'perl'
run: perl -MSwitch -e 1 2>/dev/null || (sudo apt-get update -qq && sudo apt-get install -y libswitch-perl)
# Likewise for pwsh on the powershell/ job - some runner images
# ship it, some don't; install from Microsoft's own repo if it's
# missing rather than assuming either way.
- name: Ensure PowerShell (pwsh) is available
if: matrix.name == 'powershell'
run: |
if ! command -v pwsh > /dev/null; then
sudo apt-get update -qq
sudo apt-get install -y -qq wget apt-transport-https software-properties-common
. /etc/os-release
wget -q "https://packages.microsoft.com/config/ubuntu/${VERSION_ID}/packages-microsoft-prod.deb" -O /tmp/packages-microsoft-prod.deb
sudo dpkg -i /tmp/packages-microsoft-prod.deb
sudo apt-get update -qq
sudo apt-get install -y -qq powershell
fi
# go.mod pins `go 1.23` (f03 needs its range-over-func iterators,
# added in 1.23) - setup-go's version resolution honors that as a
# floor, so this just needs to be at least that recent.
- name: Set up Go
if: matrix.name == 'go'
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Set up Rust
if: matrix.name == 'rust'
uses: dtolnay/rust-toolchain@stable
# 17, not the README's stated "11+" floor: a20/b30 use text
# blocks (`"""`), a standard (non-preview) feature only since
# Java 15 - matching Corretto 17, what lessons/compiled_lang/java's own
# README says these lessons were actually built and tested
# against.
- name: Set up Java
if: matrix.name == 'java'
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '17'
# cs/'s Makefile builds every lesson with Native AOT (see its own
# header comment), which needs a native linker on top of the
# SDK - clang is ubuntu's documented option (see cs/README.md's
# Install section), same role g++ plays for cpp/ above.
- name: Ensure clang is available
if: matrix.name == 'cs'
run: command -v clang || (sudo apt-get update -qq && sudo apt-get install -y clang)
# cs/README.md documents .NET 10 throughout (dotnet-install.sh
# --channel 10, dotnet-sdk-10.0, ...) - matching that here keeps
# CI on the same SDK line these lessons are documented against.
- name: Set up .NET SDK
if: matrix.name == 'cs'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Run rake
working-directory: ${{ matrix.dir }}
run: rake