Merge pull request #2095 from momoko-h/DiscreteDistribution #2975
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub CI | |
on: | |
push: | |
branches: [ master, nightly ] | |
tags: [ '**' ] | |
pull_request: | |
types: [ opened, synchronize, reopened ] | |
jobs: | |
ci-build: | |
strategy: | |
fail-fast: false | |
matrix: | |
cfg: | |
- name: Linux | |
os: ubuntu-20.04 | |
target: linux | |
- name: Linux mingw64 | |
os: ubuntu-22.04 | |
target: linux-mingw64 | |
- name: Mac | |
os: macos-12 | |
target: mac | |
- name: Android | |
os: ubuntu-20.04 | |
target: android | |
name: ${{ matrix.cfg.name }} ${{ github.ref }} | |
runs-on: ${{ matrix.cfg.os }} | |
steps: | |
- name: Free Disk Space (Ubuntu) | |
uses: jlumbroso/free-disk-space@main | |
if: ${{ startsWith(matrix.cfg.os, 'ubuntu') }} | |
with: | |
tool-cache: false | |
android: false | |
dotnet: true | |
haskell: true | |
large-packages: false | |
docker-images: true | |
swap-storage: true | |
- name: Context in env | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
JOB_CONTEXT: ${{ toJson(job) }} | |
STEPS_CONTEXT: ${{ toJson(steps) }} | |
RUNNER_CONTEXT: ${{ toJson(runner) }} | |
STRATEGY_CONTEXT: ${{ toJson(strategy) }} | |
MATRIX_CONTEXT: ${{ toJson(matrix) }} | |
run: '' | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Compiler cache (sccache) | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/sccache | |
~/Library/Caches/Mozilla.sccache | |
key: ${{ matrix.cfg.target }}-sccache-v1-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
${{ matrix.cfg.target }}-sccache-v1-${{ github.ref }}- | |
${{ matrix.cfg.target }}-sccache-v1-refs/heads/master- | |
${{ matrix.cfg.target }}-sccache-v1- | |
- name: Cache Rust deps and build output | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
~/.cargo/registry/index | |
~/.cargo/registry/cache | |
~/.cargo/git/db | |
~/.rustup | |
key: ${{ matrix.cfg.target }}-rust-v2-${{ hashFiles('rust') }} | |
restore-keys: | | |
${{ matrix.cfg.target }}-rust-v2-${{ hashFiles('rust') }} | |
${{ matrix.cfg.target }}-rust-v2- | |
- name: Set up JDK 18 | |
uses: actions/setup-java@v4 | |
if: matrix.cfg.target == 'android' | |
with: | |
distribution: temurin | |
java-version: 18 | |
cache: 'gradle' | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
if: matrix.cfg.target == 'android' | |
- name: Set up environment | |
shell: bash | |
run: | | |
. ${{ github.workspace }}/.ci/ci-setup.sh 2>&1 | |
echo "PATH=$PATH" >> $GITHUB_ENV | |
env: | |
CI_TARGET: ${{ matrix.cfg.target }} | |
ANDROID_KEYSTORE_FILE: ${{ secrets.ANDROID_KEYSTORE_FILE }} | |
- name: Build and run tests | |
shell: bash | |
run: ${{ github.workspace }}/.ci/ci-build.sh 2>&1 | |
env: | |
CI_NAME: ${{ matrix.cfg.name }} | |
CI_OS: ${{ matrix.cfg.os }} | |
CI_TARGET: ${{ matrix.cfg.target }} | |
CI_REF: ${{ github.ref }} | |
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} | |
- name: Publish packages | |
shell: bash | |
working-directory: ${{ github.workspace }} | |
run: ${{ github.workspace }}/.ci/ci-publish.sh 2>&1 | |
env: | |
CI_REF: ${{ github.ref }} | |
GCLOUD_CREDENTIALS_SALT: ${{ secrets.GCLOUD_CREDENTIALS_SALT }} | |
GCLOUD_CREDENTIALS_KEY: ${{ secrets.GCLOUD_CREDENTIALS_KEY }} | |
GCLOUD_CREDENTIALS_IV: ${{ secrets.GCLOUD_CREDENTIALS_IV }} | |
- name: Upload android cmake logs | |
uses: actions/upload-artifact@v4 | |
if: failure() && matrix.cfg.target == 'android' | |
with: | |
name: android-cmake-logs | |
path: | | |
**/*/cmake_server_log.txt | |
**/*/CMakeOutput.log | |
- name: Collect artifacts | |
shell: bash | |
run: | | |
set -e | |
set -x | |
mkdir artifacts | |
for file in ci-build/ja2-stracciatella_*; do | |
cp "${file}" artifacts/ | |
done | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts ${{ matrix.cfg.name }} | |
path: ${{ github.workspace }}/artifacts | |
ci-lint: | |
strategy: | |
fail-fast: false | |
matrix: | |
cfg: | |
- os: ubuntu-latest | |
target: linux | |
- os: macos-latest | |
target: mac | |
- os: windows-latest | |
target: windows | |
name: lint ${{ matrix.cfg.target }} ${{ github.ref }} | |
runs-on: ${{ matrix.cfg.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install rustup | |
shell: bash | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSfL https://sh.rustup.rs | sh -s -- -y --default-toolchain=$(cat ./rust-toolchain) | |
- name: Run cargo fmt | |
shell: bash | |
working-directory: ./rust | |
run: cargo fmt --verbose --all --check | |
- name: Run cargo clippy | |
shell: bash | |
working-directory: ./rust | |
run: cargo clippy --all-targets --all-features --verbose -- -D warnings |