Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 116 additions & 12 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,131 @@ on:
- master

jobs:
build:
name: Build
linux:
name: Linux

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
makefile: Makefile.msvc
- os: ubuntu-latest
makefile: Makefile
- compiler: clang
cxxcompiler: clang++
- compiler: gcc
cxxcompiler: g++

runs-on: ubuntu-latest
env:
CC: ${{ matrix.compiler }}
CXX: ${{ matrix.cxxcompiler }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master

- name: Build
run: |
mkdir build
cd build

echo "::group::CMake"
cmake ..
echo "::endgroup::"

echo "::group::Build"
echo "Running on $(nproc) cores"
cmake --build . -j $(nproc)
echo "::endgroup::"

macos:
name: Mac OS

strategy:
fail-fast: false
matrix:
include:
- arch: arm64
full_arch: arm64

runs-on: macos-latest
env:
MACOSX_DEPLOYMENT_TARGET: 10.13

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master

- name: Build
run: |
mkdir build
cd build

echo "::group::CMake"
cmake ${GITHUB_WORKSPACE} \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.full_arch }} \
# EOF
echo "::endgroup::"

echo "::group::Build"
echo "Running on $(sysctl -n hw.logicalcpu) cores"
cmake --build . -j $(sysctl -n hw.logicalcpu)
echo "::endgroup::"

windows:
name: Windows

strategy:
fail-fast: false
matrix:
os: [windows-latest]
arch: [x86, x64]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Building the 64 bits version with MSVC (which we didn't before), unearthed a compiler warning at line 236 of sample.cpp.


runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set build environment
if: matrix.os == 'windows-latest'
uses: actions/checkout@v4

- name: Install MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master

- name: Configure developer command prompt for ${{ matrix.arch }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x86
arch: ${{ matrix.arch }}

- name: Build
run: make -f ${{ matrix.makefile }}
shell: bash
run: |
mkdir build
cd build

echo "::group::CMake"
cmake .. \
-GNinja \
# EOF
echo "::endgroup::"

echo "::group::Build"
cmake --build .
echo "::endgroup::"

check_annotations:
name: Check Annotations
needs:
- linux
- macos
- windows

if: always() && github.event_name == 'pull_request'

runs-on: ubuntu-latest

steps:
- name: Check annotations
uses: OpenTTD/actions/annotation-check@v5
36 changes: 3 additions & 33 deletions .github/workflows/commit-checker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,42 +10,12 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 4

- name: Get pull-request commits
run: |
set -x
# actions/checkout did a merge checkout of the pull-request. As such, the first
# commit is the merge commit. This means that on HEAD^ is the base branch, and
# on HEAD^2 are the commits from the pull-request. We now check if those trees
# have a common parent. If not, we fetch a few more commits till we do. In result,
# the log between HEAD^ and HEAD^2 will be the commits in the pull-request.
DEPTH=4
while [ -z "$(git merge-base HEAD^ HEAD^2)" ]; do
# Prevent infinite recursion
if [ ${DEPTH} -gt 256 ]; then
echo "No common parent between '${GITHUB_HEAD_REF}' and '${GITHUB_BASE_REF}'." >&2
exit 1
fi

git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --deepen=${DEPTH} origin HEAD
DEPTH=$(( ${DEPTH} * 4 ))
done

# Just to show which commits we are going to evaluate.
git log --oneline HEAD^..HEAD^2

- name: Checkout commit-checker
uses: actions/checkout@v2
with:
repository: OpenTTD/OpenTTD-git-hooks
path: git-hooks
ref: master
uses: OpenTTD/actions/checkout-pull-request@v5

- name: Check commits
run: |
set -x
HOOKS_DIR=./git-hooks/hooks GIT_DIR=.git ./git-hooks/hooks/check-commits.sh HEAD^..HEAD^2
echo "Commit checks passed"
uses: OpenTTD/OpenTTD-git-hooks@main
117 changes: 117 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: Release

on:
release:
types:
- published

jobs:
source:
name: Source

runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Generate .version
run: |
cmake -DWRITE_VERSION=1 -P generate_version.cmake

- name: Create bundles
run: |
FOLDER_NAME=catcodec-${{ github.event.release.tag_name }}

# Rename the folder to catcodec-NNN
mkdir ${FOLDER_NAME}
find . -maxdepth 1 -not -name . -not -name .git -not -name ${FOLDER_NAME} -exec mv {} ${FOLDER_NAME}/ \;

mkdir -p build/bundles

echo "::group::Create tarball (xz) bundle"
tar --xz -cvf build/bundles/${FOLDER_NAME}-source.tar.xz ${FOLDER_NAME}
echo "::endgroup::"

echo "::group::Create zip bundle"
zip -9 -r build/bundles/${FOLDER_NAME}-source.zip ${FOLDER_NAME}
echo "::endgroup::"

- name: Store bundles
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} build/bundles/*

windows:
needs: source

strategy:
fail-fast: false
matrix:
arch: [x86, x64]

name: Windows (${{ matrix.arch }})

runs-on: windows-latest

steps:
- name: Prepare build dir for gh usage
shell: bash
run: |
git init build
cd build
git remote add origin ${{ github.event.repository.html_url }}

- name: Download source
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
cd build
gh release download ${{ github.event.release.tag_name }} -p "*.xz" -D ..

- name: Unpack source
shell: bash
run: |
tar --xz -xf *-source.tar.xz --strip-components=1

- name: Install MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master

- name: Configure developer command prompt for ${{ matrix.arch }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}

- name: Build
shell: bash
run: |
cd build

echo "::group::CMake"
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
# EOF
echo "::endgroup::"

echo "::group::Build"
cmake --build .
echo "::endgroup::"

- name: Create bundles
shell: bash
run: |
cd build
echo "::group::Run CPack"
cpack
echo "::endgroup::"

- name: Store bundles
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
cd build
gh release upload ${{ github.event.release.tag_name }} bundles/*
Loading
Loading