-
Notifications
You must be signed in to change notification settings - Fork 4
123 lines (108 loc) · 5.67 KB
/
ci.yml
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
name: CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
schedule:
# Runs at 15:00 UTC on Fri
- cron: "0 15 * * 5"
workflow_dispatch:
# This allows running it on any branch manually:
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
env:
CARGO_TERM_COLOR: always
# Deny warns here as a catch-all and because some commands (e.g. cargo build) don't accept `--deny warnings`
# but also deny them on all individual cargo invocations where applicable because:
# 1) Some commands might not support rustflags (e.g. clippy didn't at first, cargo doc uses a different var, ...)
# 2) People (or me) might copy paste the commands into CI where this flag is missing without noticing.
RUSTFLAGS: --deny warnings
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
rust: [stable, nightly]
# For reference: https://github.com/actions/virtual-environments#available-environments
os: [ubuntu-latest, windows-latest, macos-latest]
exclude:
# Each minute of MacOS CI counts as 10 minutes towards the limit
# (https://docs.github.com/en/billing/managing-billing-for-github-actions/about-billing-for-github-actions#minute-multipliers)
# and nightly doesn't benefit from caching much
# so this combination would take up the vast majority of the free CI limit.
- os: macos-latest
rust: nightly
steps:
- name: Install linux deps
if: ${{ matrix.os == 'ubuntu-latest' }}
# Run update first or install might start failing eventually
run: |
sudo apt-get update
# Fyrox deps
sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev pkg-config xorg-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libxkbcommon-x11-dev libgl1-mesa-glx
# Add OpenGL libs to the CI runner because Fyrox currently has no headless mode
sudo apt-get install --no-install-recommends -y libegl1-mesa libegl1
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
# Caching must be after toolchain selection
- uses: Swatinem/rust-cache@v2
- name: Print versions
run: rustc --version && cargo --version
- name: Build native
# Use build instead of check since it needs to be built for tests anyway
run: cargo build --verbose --all-features
- name: Run tests
run: cargo test --verbose --all-features
# We wanna run on all OSes to detect nondeterminism.
# LATER Actually test the output is the same, not just that there are no errors.
# LATER Also run separate client and server, test the output is the same as local mode.
# Headless mode is necessary:
# - On linux I could use xvfb-run but there would still be issues with ALSA.
# I made a PR to Fyrox to allow disabling sound but eventually it got turned into a full headless mode
# which disables graphics too, there's no way to disable just sound.
# Adding a mode with graphics but without sound is probably not worth it, it wouldn't catch many more bugs.
# - Windows and macOS don't even have xvfb-run.
- name: Run the game (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
# Linux needs xvfb-run for now, otherwise we get this error, idk why, maybe winit bug?:
# thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoCompositorListening X11 status: XOpenDisplayFailed', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.28.6/src/platform_impl/linux/mod.rs:757:9
run: RUST_BACKTRACE=1 xvfb-run cargo run --color=always --verbose --all-features -- local cl_headless 1 d_exit_after_one_frame 1 d_testing 1 2>&1 | tee output.log
- name: Run the game (Windows and macOS)
if: ${{ matrix.os != 'ubuntu-latest' }}
run: RUST_BACKTRACE=1 cargo run --color=always --verbose --all-features -- local cl_headless 1 d_exit_after_one_frame 1 d_testing 1 2>&1 | tee output.log
shell: bash # Force bash even on Windows
- name: Detect errors
# There should be 6 errors in the output, those are printed on purpose.
# A different number means something is wrong.
# If the condition and therefore the echo succeed,
# invert the result with `!` to signal test failure.
run: '! ( [ $(grep "ERROR" output.log | wc -l) != 6 ] && echo Wrong number of ERRORs in output )'
shell: bash # Force bash even on Windows
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: cargo fmt --version
- run: cargo fmt -- --check
lint:
runs-on: ubuntu-latest
steps:
- name: Install linux deps
# Run update first or install might start failing eventually
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libasound2-dev libudev-dev pkg-config xorg-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
- uses: actions/checkout@v3
# Use rust-toolchain because GHA tends to still have an old version for a few days after a new Rust release.
- uses: dtolnay/rust-toolchain@stable
# Caching must be after toolchain selection
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --version
# Use --all-targets to also check tests.
# Note that --all-features doesn't check all code when something is *disabled* by a feature.
- run: cargo clippy --all-targets --all-features -- --deny warnings
- run: ./extra-lints.sh