first attempt at a reusable workflow

develop
Myk Taylor 2023-07-30 19:36:12 -07:00
parent 7514dd2cba
commit 1faf156bfc
No known key found for this signature in database
2 changed files with 167 additions and 179 deletions

@ -0,0 +1,110 @@
name: build-linux
on:
workflow_call:
inputs:
artifact-name:
type: string
append-date-and-hash:
type: boolean
default: false
cache-id:
type: string
default: ''
platform-files:
type: boolean
default: true
common-files:
type: boolean
default: true
docs:
type: boolean
default: false
stonesense:
type: boolean
default: true
extras:
type: boolean
default: false
gcc-ver:
type: string
default: "11"
jobs:
build-linux64:
name: Linux package
runs-on: ubuntu-22.04
steps:
- name: Install basic build dependencies
run: |
sudo apt-get update
sudo apt-get install ninja-build
- name: Install binary build dependencies
if: inputs.platform-files
run: |
sudo apt-get install \
ccache \
gcc-${{ inputs.gcc-ver }} \
g++-${{ inputs.gcc-ver }} \
libxml-libxslt-perl
- name: Install stonesense dependencies
if: inputs.stonesense
run: sudo apt-get install libgl-dev
- name: Install doc dependencies
if: inputs.docs
run: pip install 'sphinx<4.4.0'
- name: Clone DFHack
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: ${{ !inputs.platform-files && 1 || 0 }}
- name: Fetch ccache
if: inputs.platform-files
uses: actions/cache@v3
with:
path: ~/.ccache
key: linux-gcc-${{ inputs.gcc-ver }}-${{ inputs.cache-id }}-${{ github.sha }}
restore-keys: |
linux-gcc-${{ inputs.gcc-ver }}-${{ inputs.cache-id }}
linux-gcc-${{ inputs.gcc-ver }}
- name: Configure DFHack
env:
CC: gcc-${{ inputs.gcc-ver }}
CXX: g++-${{ inputs.gcc-ver }}
run: |
cmake \
-S . \
-B build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=build/image \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_LIBRARY:BOOL=${{ inputs.platform-files }} \
-DBUILD_PLUGINS:BOOL=${{ inputs.platform-files }} \
-DBUILD_STONESENSE:BOOL=${{ inputs.platform-files }} \
-DBUILD_DEV_PLUGINS:BOOL=${{ inputs.extras }} \
-DBUILD_SIZECHECK:BOOL=${{ inputs.extras }} \
-DBUILD_SKELETON:BOOL=${{ inputs.extras }} \
-DBUILD_DOCS:BOOL=${{ inputs.docs }} \
-DINSTALL_DATA_FILES:BOOL=${{ inputs.common-files }} \
-DINSTALL_SCRIPTS:BOOL=${{ inputs.common-files }}
- name: Build DFHack
run: ninja -C build install
- name: Run cpp tests
run: ninja -C build test
- name: Trim cache
if: inputs.platform-files
run: |
ccache --max-size 50M
ccache --cleanup
ccache --show-stats
- name: Format artifact name
if: ${{ inputs.append-date-and-hash }}
id: artifactname
run: |
echo name=${{ inputs.artifact-name }}-$(date +%Y%m%d)-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Upload artifact
if: inputs.artifact-name
uses: actions/upload-artifact@v3
with:
name: ${{ inputs.append-date-and-hash && inputs.artifact-name || steps.artifactname.outputs.name}}
path: build/image/*

@ -3,98 +3,62 @@ name: Build
on: [push, pull_request]
jobs:
build-test:
runs-on: ${{ matrix.os }}
build-linux:
name: Build (Linux ${{ matrix.type }}, GCC ${{ matrix.gcc }})
uses: ./.github/workflows/build-linux.yml
with:
artifact-name: ${{ matrix.artifact-name != 0 && matrix.artifact-name || format('{0}-gcc-{1}', matrix.type, matrix.gcc) }}
append-date-and-hash: ${{ matrix.append-date-and-hash }}
cache-id: ${{ matrix.type }}
stonesense: ${{ matrix.stonesense }}
docs: ${{ matrix.type == 'release' }}
extras: ${{ matrix.extras }}
gcc-ver: ${{ matrix.gcc }}
secrets: inherit
strategy:
fail-fast: false
matrix:
include:
- type: release
gcc: "10"
artifact-name: dfhack-linux64
append-date-and-hash: true
stonesense: true
extras: false
- type: test
gcc: "10"
stonesense: false
extras: false
- type: test
gcc: "12"
stonesense: true
extras: true
test-linux:
name: Test (Linux, GCC ${{ matrix.gcc }}, ${{ matrix.plugins }} plugins)
needs: build-linux
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
gcc:
- 10
plugins:
- default
gcc: [10]
plugins: [default]
include:
- os: ubuntu-22.04
gcc: 12
- gcc: 12
plugins: all
steps:
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install \
ccache \
libgl-dev \
libxml-libxslt-perl \
ninja-build
pip install 'sphinx<4.4.0'
- name: Install GCC
run: |
sudo apt-get install gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
- name: Clone DFHack
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Set up environment
id: env_setup
run: |
DF_VERSION="$(sh ci/get-df-version.sh)"
echo "df_version=${DF_VERSION}" >> $GITHUB_OUTPUT
echo "DF_VERSION=${DF_VERSION}" >> $GITHUB_ENV
echo "DF_FOLDER=${HOME}/DF/${DF_VERSION}/df_linux" >> $GITHUB_ENV
echo "CCACHE_DIR=${HOME}/.ccache" >> $GITHUB_ENV
- name: Fetch ccache
uses: actions/cache@v3
- name: Download artifact
uses: actions/download-artifact@v3
with:
path: ~/.ccache
key: ccache-${{ matrix.os }}-gcc-${{ matrix.gcc }}-test-${{ github.sha }}
restore-keys: |
ccache-${{ matrix.os }}-gcc-${{ matrix.gcc }}-test
ccache-${{ matrix.os }}-gcc-${{ matrix.gcc }}
name: test-${{ matrix.gcc }}
# - name: Fetch DF cache
# uses: actions/cache@v3
# with:
# path: ~/DF
# key: df-${{ steps.env_setup.outputs.df_version }}-${{ hashFiles('ci/download-df.sh') }}
# key: df-${{ hashFiles('ci/download-df.sh') }}
# - name: Download DF
# run: |
# sh ci/download-df.sh
- name: Configure DFHack
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
run: |
cmake \
-S . \
-B build-ci \
-G Ninja \
-DCMAKE_INSTALL_PREFIX="$DF_FOLDER" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DDFHACK_BUILD_ARCH=64 \
-DBUILD_DEV_PLUGINS:BOOL=${{ matrix.plugins == 'all' }} \
-DBUILD_SIZECHECK:BOOL=${{ matrix.plugins == 'all' }} \
-DBUILD_SKELETON:BOOL=${{ matrix.plugins == 'all' }} \
-DBUILD_STONESENSE:BOOL=${{ matrix.plugins == 'all' }} \
-DBUILD_TESTS:BOOL=ON
- name: Build DFHack
run: |
ninja -C build-ci install
ccache --max-size 50M
ccache --cleanup
ccache --show-stats
- name: Run cpp unit tests
id: run_tests_cpp
run: |
ninja -C build-ci test
exit $?
# - name: Run lua tests
# id: run_tests_lua
# run: |
@ -119,81 +83,16 @@ jobs:
# run: |
# rm -rf "$DF_FOLDER"
build-linux64:
name: Linux package
runs-on: ubuntu-22.04
steps:
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install \
ccache \
gcc-10 \
g++-10 \
libgl-dev \
libxml-libxslt-perl \
ninja-build
pip install 'sphinx<4.4.0'
- name: Clone DFHack
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 0
- name: Fetch ccache
uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache-ubuntu-22.04-gcc-10-${{ github.sha }}
restore-keys: |
ccache-ubuntu-22.04-gcc-10
- name: Set up environment
id: env_setup
run: |
echo "CCACHE_DIR=${HOME}/.ccache" >> $GITHUB_ENV
- name: Configure DFHack
env:
CC: gcc-10
CXX: g++-10
run: |
cmake \
-S . \
-B build \
-G Ninja \
-DCMAKE_INSTALL_PREFIX=build/output \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DDFHACK_BUILD_ARCH=64 \
-DBUILD_DOCS:BOOL=1 \
-DBUILD_STONESENSE:BOOL=1
- name: Build DFHack
run: |
ninja -C build install
ccache --max-size 50M
ccache --cleanup
ccache --show-stats
- name: Format artifact name
id: artifactname
run: |
echo name=$(date +%Y%m%d)-$(git rev-parse --short HEAD) >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: dfhack-linux64-build-${{ steps.artifactname.outputs.name }}
path: build/output/*
package-win64:
name: Win64 package (native)
runs-on: windows-latest
steps:
- run: pip install clcache
- run: pip install 'sphinx<4.4.0'
- name: Fetch cache
uses: actions/cache@v3
with:
path: "%HOME%/clcache"
path: ~/clcache
key: clcache-win64-${{ github.sha }}
restore-keys: |
clcache-win64
@ -202,8 +101,6 @@ jobs:
with:
submodules: true
fetch-depth: 0
- run: pip install clcache
- run: pip install 'sphinx<4.4.0'
- name: Configure DFHack
run: cmake -S . -B build -G "Visual Studio 17 2022" -DCMAKE_INSTALL_PREFIX=build/image -DCMAKE_C_COMPILER_LAUNCHER=clcache -DCMAKE_CXX_COMPILER_LAUNCHER=clcache -DBUILD_DOCS:BOOL=1 -DBUILD_STONESENSE:BOOL=1
- name: Build DFHack
@ -257,30 +154,16 @@ jobs:
path: build/win64-cross/output/*
docs:
runs-on: ubuntu-22.04
steps:
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install dependencies
run: |
pip install 'sphinx'
- name: Clone DFHack
uses: actions/checkout@v3
uses: ./.github/workflows/build-linux.yml
with:
submodules: true
- name: Build docs
run: |
sphinx-build -W --keep-going -j auto --color . docs/html
platform-files: false
common-files: false
docs: true
secrets: inherit
lint:
runs-on: ubuntu-22.04
steps:
- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: 3
- name: Install Lua
run: |
sudo apt-get update
@ -289,22 +172,17 @@ jobs:
uses: actions/checkout@v3
with:
submodules: true
# don't need tags here
- name: Check whitespace
run: |
python ci/lint.py --git-only --github-actions
run: python ci/lint.py --git-only --github-actions
- name: Check Authors.rst
if: success() || failure()
run: |
python ci/authors-rst.py
if: always()
run: python ci/authors-rst.py
- name: Check for missing documentation
if: success() || failure()
run: |
python ci/script-docs.py
if: always()
run: python ci/script-docs.py
- name: Check Lua syntax
if: success() || failure()
run: |
python ci/script-syntax.py --ext=lua --cmd="luac5.3 -p" --github-actions
if: always()
run: python ci/script-syntax.py --ext=lua --cmd="luac5.3 -p" --github-actions
check-pr:
runs-on: ubuntu-latest