2021-10-12 04:36:45 +08:00
|
|
|
name: CI
|
|
|
|
|
2023-11-04 03:41:48 +08:00
|
|
|
env:
|
2021-10-12 04:36:45 +08:00
|
|
|
# MIN_SUPPORTED_RUST_VERSION: "1.46.0"
|
|
|
|
# CICD_INTERMEDIATES_DIR: "_cicd-intermediates"
|
2023-11-04 03:41:48 +08:00
|
|
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
2024-07-23 23:31:36 +08:00
|
|
|
# vcpkg version: 2024.06.15
|
2023-11-04 03:41:48 +08:00
|
|
|
# for multiarch gcc compatibility
|
2024-07-23 23:31:36 +08:00
|
|
|
VCPKG_COMMIT_ID: "f7423ee180c4b7f40d43402c2feb3859161ef625"
|
2021-10-12 04:36:45 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
pull_request:
|
2023-02-22 13:24:16 +08:00
|
|
|
paths-ignore:
|
|
|
|
- "docs/**"
|
|
|
|
- "README.md"
|
2021-10-12 04:36:45 +08:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2022-10-20 17:16:15 +08:00
|
|
|
paths-ignore:
|
|
|
|
- ".github/**"
|
2023-02-22 13:24:16 +08:00
|
|
|
- "docs/**"
|
|
|
|
- "README.md"
|
2024-05-03 16:12:36 +08:00
|
|
|
- "res/**"
|
2024-05-05 16:44:59 +08:00
|
|
|
- "appimage/**"
|
|
|
|
- "flatpak/**"
|
2021-10-12 04:36:45 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
# ensure_cargo_fmt:
|
|
|
|
# name: Ensure 'cargo fmt' has been run
|
|
|
|
# runs-on: ubuntu-20.04
|
|
|
|
# steps:
|
|
|
|
# - uses: actions-rs/toolchain@v1
|
|
|
|
# with:
|
|
|
|
# toolchain: stable
|
|
|
|
# default: true
|
|
|
|
# profile: minimal
|
|
|
|
# components: rustfmt
|
2022-09-17 19:26:01 +08:00
|
|
|
# - uses: actions/checkout@v3
|
2021-10-12 04:36:45 +08:00
|
|
|
# - run: cargo fmt -- --check
|
|
|
|
|
|
|
|
# min_version:
|
|
|
|
# name: Minimum supported rust version
|
|
|
|
# runs-on: ubuntu-20.04
|
|
|
|
# steps:
|
|
|
|
# - name: Checkout source code
|
2022-09-17 19:26:01 +08:00
|
|
|
# uses: actions/checkout@v3
|
2021-10-12 04:36:45 +08:00
|
|
|
|
|
|
|
# - name: Install rust toolchain (v${{ env.MIN_SUPPORTED_RUST_VERSION }})
|
|
|
|
# uses: actions-rs/toolchain@v1
|
|
|
|
# with:
|
|
|
|
# toolchain: ${{ env.MIN_SUPPORTED_RUST_VERSION }}
|
|
|
|
# default: true
|
|
|
|
# profile: minimal # minimal component installation (ie, no documentation)
|
|
|
|
# components: clippy
|
|
|
|
# - name: Run clippy (on minimum supported rust version to prevent warnings we can't fix)
|
|
|
|
# uses: actions-rs/cargo@v1
|
|
|
|
# with:
|
|
|
|
# command: clippy
|
|
|
|
# args: --locked --all-targets --all-features -- --allow clippy::unknown_clippy_lints
|
|
|
|
# - name: Run tests
|
|
|
|
# uses: actions-rs/cargo@v1
|
|
|
|
# with:
|
|
|
|
# command: test
|
|
|
|
# args: --locked
|
|
|
|
|
|
|
|
build:
|
|
|
|
name: ${{ matrix.job.target }} (${{ matrix.job.os }})
|
|
|
|
runs-on: ${{ matrix.job.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
job:
|
|
|
|
# - { target: aarch64-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
|
|
|
|
# - { target: arm-unknown-linux-gnueabihf , os: ubuntu-20.04, use-cross: true }
|
|
|
|
# - { target: arm-unknown-linux-musleabihf, os: ubuntu-20.04, use-cross: true }
|
2024-04-20 18:19:19 +08:00
|
|
|
# - { target: i686-pc-windows-msvc , os: windows-2022 }
|
2021-10-12 04:36:45 +08:00
|
|
|
# - { target: i686-unknown-linux-gnu , os: ubuntu-20.04, use-cross: true }
|
|
|
|
# - { target: i686-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
|
|
|
|
# - { target: x86_64-apple-darwin , os: macos-10.15 }
|
2024-04-20 18:19:19 +08:00
|
|
|
# - { target: x86_64-pc-windows-gnu , os: windows-2022 }
|
|
|
|
# - { target: x86_64-pc-windows-msvc , os: windows-2022 }
|
2021-10-12 04:36:45 +08:00
|
|
|
- { target: x86_64-unknown-linux-gnu , os: ubuntu-20.04 }
|
|
|
|
# - { target: x86_64-unknown-linux-musl , os: ubuntu-20.04, use-cross: true }
|
|
|
|
steps:
|
2023-11-04 03:41:48 +08:00
|
|
|
- name: Export GitHub Actions cache environment variables
|
|
|
|
uses: actions/github-script@v6
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
|
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
|
|
|
2021-10-12 04:36:45 +08:00
|
|
|
- name: Checkout source code
|
2023-12-13 21:22:38 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-10-12 04:36:45 +08:00
|
|
|
|
|
|
|
- name: Install prerequisites
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
case ${{ matrix.job.target }} in
|
2023-11-04 03:41:48 +08:00
|
|
|
x86_64-unknown-linux-gnu)
|
|
|
|
sudo apt-get -y update
|
|
|
|
sudo apt-get install -y \
|
|
|
|
clang \
|
|
|
|
cmake \
|
|
|
|
curl \
|
|
|
|
gcc \
|
|
|
|
git \
|
|
|
|
g++ \
|
2024-05-03 02:57:24 +08:00
|
|
|
libpam0g-dev \
|
2023-11-04 03:41:48 +08:00
|
|
|
libasound2-dev \
|
|
|
|
libgstreamer1.0-dev \
|
|
|
|
libgstreamer-plugins-base1.0-dev \
|
|
|
|
libgtk-3-dev \
|
|
|
|
libpulse-dev \
|
2024-07-23 23:31:36 +08:00
|
|
|
libva-dev \
|
|
|
|
libvdpau-dev \
|
2023-11-04 03:41:48 +08:00
|
|
|
libxcb-randr0-dev \
|
|
|
|
libxcb-shape0-dev \
|
|
|
|
libxcb-xfixes0-dev \
|
|
|
|
libxdo-dev \
|
|
|
|
libxfixes-dev \
|
|
|
|
nasm \
|
2023-11-15 22:03:40 +08:00
|
|
|
wget
|
2023-11-04 03:41:48 +08:00
|
|
|
;;
|
2021-10-12 04:36:45 +08:00
|
|
|
# arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
|
|
|
|
# aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
|
|
|
|
esac
|
|
|
|
|
2023-11-04 03:41:48 +08:00
|
|
|
- name: Setup vcpkg with Github Actions binary cache
|
|
|
|
uses: lukka/run-vcpkg@v11
|
2021-10-12 04:36:45 +08:00
|
|
|
with:
|
2023-11-04 03:41:48 +08:00
|
|
|
vcpkgDirectory: /opt/artifacts/vcpkg
|
|
|
|
vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
|
|
|
|
|
2021-10-12 04:40:06 +08:00
|
|
|
- name: Install vcpkg dependencies
|
|
|
|
run: |
|
2023-11-04 03:41:48 +08:00
|
|
|
$VCPKG_ROOT/vcpkg install --x-install-root="$VCPKG_ROOT/installed"
|
|
|
|
shell: bash
|
2022-09-12 12:50:51 +08:00
|
|
|
|
|
|
|
- name: Install Rust toolchain
|
2023-11-23 22:47:54 +08:00
|
|
|
uses: dtolnay/rust-toolchain@v1
|
2022-09-12 12:50:51 +08:00
|
|
|
with:
|
|
|
|
toolchain: stable
|
2023-11-23 22:47:54 +08:00
|
|
|
targets: ${{ matrix.job.target }}
|
|
|
|
components: ''
|
2021-10-12 04:36:45 +08:00
|
|
|
|
|
|
|
- name: Show version information (Rust, cargo, GCC)
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
gcc --version || true
|
|
|
|
rustup -V
|
|
|
|
rustup toolchain list
|
|
|
|
rustup default
|
|
|
|
cargo -V
|
|
|
|
rustc -V
|
|
|
|
|
2023-11-23 04:38:41 +08:00
|
|
|
- uses: Swatinem/rust-cache@v2
|
2023-11-04 03:41:48 +08:00
|
|
|
|
2022-09-12 12:50:51 +08:00
|
|
|
- name: Build
|
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
use-cross: ${{ matrix.job.use-cross }}
|
|
|
|
command: build
|
2023-07-24 15:31:36 +08:00
|
|
|
args: --locked --target=${{ matrix.job.target }}
|
|
|
|
|
|
|
|
- name: clean
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
cargo clean
|
2021-10-12 04:36:45 +08:00
|
|
|
|
|
|
|
# - name: Strip debug information from executable
|
|
|
|
# id: strip
|
|
|
|
# shell: bash
|
|
|
|
# run: |
|
|
|
|
# # Figure out suffix of binary
|
|
|
|
# EXE_suffix=""
|
|
|
|
# case ${{ matrix.job.target }} in
|
|
|
|
# *-pc-windows-*) EXE_suffix=".exe" ;;
|
|
|
|
# esac;
|
|
|
|
|
|
|
|
# # Figure out what strip tool to use if any
|
|
|
|
# STRIP="strip"
|
|
|
|
# case ${{ matrix.job.target }} in
|
|
|
|
# arm-unknown-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
|
|
|
|
# aarch64-unknown-linux-gnu) STRIP="aarch64-linux-gnu-strip" ;;
|
|
|
|
# *-pc-windows-msvc) STRIP="" ;;
|
|
|
|
# esac;
|
|
|
|
|
|
|
|
# # Setup paths
|
|
|
|
# BIN_DIR="${{ env.CICD_INTERMEDIATES_DIR }}/stripped-release-bin/"
|
|
|
|
# mkdir -p "${BIN_DIR}"
|
|
|
|
# BIN_NAME="${{ env.PROJECT_NAME }}${EXE_suffix}"
|
|
|
|
# BIN_PATH="${BIN_DIR}/${BIN_NAME}"
|
|
|
|
|
|
|
|
# # Copy the release build binary to the result location
|
|
|
|
# cp "target/${{ matrix.job.target }}/release/${BIN_NAME}" "${BIN_DIR}"
|
|
|
|
|
|
|
|
# # Also strip if possible
|
|
|
|
# if [ -n "${STRIP}" ]; then
|
|
|
|
# "${STRIP}" "${BIN_PATH}"
|
|
|
|
# fi
|
|
|
|
|
|
|
|
# # Let subsequent steps know where to find the (stripped) bin
|
|
|
|
# echo ::set-output name=BIN_PATH::${BIN_PATH}
|
|
|
|
# echo ::set-output name=BIN_NAME::${BIN_NAME}
|
|
|
|
|
|
|
|
- name: Set testing options
|
|
|
|
id: test-options
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
# test only library unit tests and binary for arm-type targets
|
|
|
|
unset CARGO_TEST_OPTIONS
|
|
|
|
|
2023-05-17 20:51:45 +08:00
|
|
|
case ${{ matrix.job.target }} in
|
|
|
|
arm-* | aarch64-*)
|
|
|
|
CARGO_TEST_OPTIONS="--lib --bin ${PROJECT_NAME}"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
CARGO_TEST_OPTIONS="--workspace --no-fail-fast -- --skip test_get_cursor_pos --skip test_get_key_state"
|
|
|
|
;;
|
|
|
|
esac;
|
|
|
|
|
2023-11-23 04:38:41 +08:00
|
|
|
#deprecated echo ::set-output name=CARGO_TEST_OPTIONS::${CARGO_TEST_OPTIONS}
|
|
|
|
echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_ENV
|
2023-11-23 22:39:53 +08:00
|
|
|
echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT
|
2023-05-17 20:51:45 +08:00
|
|
|
|
|
|
|
- name: Run tests
|
2021-10-12 05:35:31 +08:00
|
|
|
uses: actions-rs/cargo@v1
|
|
|
|
with:
|
|
|
|
use-cross: ${{ matrix.job.use-cross }}
|
2023-05-17 20:51:45 +08:00
|
|
|
command: test
|
|
|
|
args: --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}}
|