diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62fd17d3ef..f02364c6ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,21 @@ name: CI -on: [push, pull_request] +on: + push: + paths-ignore: + - '.editorconfig' + - '.gitattributes' + - '.github/*_TEMPLATE/**' + - '.github/workflows/localisation.yml' + - '.gitignore' + - '.vscode/**' + pull_request: + paths-ignore: + - '.editorconfig' + - '.gitattributes' + - '.github/*_TEMPLATE/**' + - '.github/workflows/localisation.yml' + - '.gitignore' + - '.vscode/**' defaults: run: shell: bash @@ -17,7 +33,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 - name: Lint Commit Messages @@ -27,13 +43,14 @@ jobs: check-code-formatting: name: Check code formatting runs-on: ubuntu-latest - container: - image: openrct2/openrct2-build:4-format + container: openrct2/openrct2-build:4-format + defaults: + run: + shell: sh steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Run clang-format - shell: sh run: scripts/check-code-formatting windows: name: Windows @@ -48,7 +65,7 @@ jobs: PLATFORM: ${{ matrix.platform }} steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build OpenRCT2 run: . scripts/setenv && build - name: Build artifacts @@ -58,7 +75,7 @@ jobs: build-symbols build-installer -i - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.platform }} path: artifacts @@ -69,10 +86,10 @@ jobs: run: | . scripts/setenv -q if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH - upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH - upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH - upload-backtrace-symbols artifacts/openrct2-symbols-*.zip + upload-build artifacts/openrct2-portable-*.zip "windows-portable-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-installer-*.exe "windows-installer-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-symbols-*.zip "windows-symbols-$PLATFORM" $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-backtrace-symbols artifacts/openrct2-symbols-*.zip else echo 'Not going to push build' fi @@ -80,8 +97,7 @@ jobs: name: Windows (${{ matrix.platform_name }}) using mingw runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:4-mingw + container: openrct2/openrct2-build:4-mingw strategy: fail-fast: false matrix: @@ -97,7 +113,7 @@ jobs: build_flags: -DDISABLE_HTTP=Off -DENABLE_SCRIPTING=ON -DCMAKE_CXX_FLAGS="-Wno-error=cast-function-type -Wno-error=unused-function" -DSTATIC=on -DMINGW_TARGET_NT5_1=ON steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -105,14 +121,14 @@ jobs: - name: Build OpenRCT2 run: | sudo su - mkdir bin && cd bin - cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Release -DDISABLE_IPO=on -DFORCE32=on ${{ matrix.build_flags }} + cmake -B bin -G Ninja -DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt -DCMAKE_BUILD_TYPE=Release -DDISABLE_IPO=on -DFORCE32=on ${{ matrix.build_flags }} + cd bin ninja -k0 - name: Upload artifacts (CI) if: matrix.platform == 'NT5.1' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: - name: OpenRCT2-${{ matrix.platform }} + name: OpenRCT2-Windows-${{ matrix.platform }} path: bin/openrct2.exe if-no-files-found: error macos-cmake: @@ -127,7 +143,7 @@ jobs: - arch: x64 cache_key: macos-x64 # Note: only build/run tests on the native architecture of the CI agent - # Github macos-latest agents are currently all Intel + # GitHub macos-latest agents are currently all Intel build_flags: -DARCH="x86_64" -DWITH_TESTS=on run_tests: true - arch: arm64 @@ -136,7 +152,7 @@ jobs: run_tests: false steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -157,7 +173,7 @@ jobs: cd artifacts zip -rqy openrct2-macos.zip OpenRCT2.app - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.arch }}-cmake path: artifacts/openrct2-macos.zip @@ -168,14 +184,14 @@ jobs: needs: macos-cmake steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: download x64 app bundle - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-x64-cmake path: macos_universal/x64 - name: download arm64 app bundle - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-arm64-cmake path: macos_universal/arm64 @@ -195,7 +211,7 @@ jobs: cd artifacts zip -rqy openrct2-macos.zip OpenRCT2.app - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-universal path: artifacts/openrct2-macos.zip @@ -204,16 +220,15 @@ jobs: run: | . scripts/setenv if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/openrct2-macos.zip macos $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-macos.zip macos $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH else - echo 'Not going to push build' + echo 'Not going to push build' fi linux-portable: name: Linux (${{ matrix.platform }}, ${{ matrix.distro }}, portable) runs-on: ubuntu-latest needs: check-code-formatting - container: - image: ${{ matrix.image }} + container: ${{ matrix.image }} strategy: fail-fast: false matrix: @@ -236,7 +251,7 @@ jobs: build_flags: -DFORCE32=ON -DENABLE_SCRIPTING=OFF -DCMAKE_CXX_FLAGS="-m32 -g -gz" steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -248,7 +263,7 @@ jobs: - name: Build artifacts run: . scripts/setenv -q && build-portable artifacts/OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }}.tar.gz bin/install/usr - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }} path: artifacts @@ -260,19 +275,18 @@ jobs: run: | . scripts/setenv -q if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }}.tar.gz linux-${{ matrix.platform }} $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/OpenRCT2-${{ runner.os }}-${{ matrix.distro }}-${{ matrix.platform }}.tar.gz linux-${{ matrix.platform }} $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH else - echo 'Not going to push build' + echo 'Not going to push build' fi linux-appimage: name: Linux (x64, AppImage) runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:0.3.1-bionic + container: openrct2/openrct2-build:0.3.1-bionic steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -284,7 +298,7 @@ jobs: - name: Build AppImage run: . scripts/setenv -q && build-appimage - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-AppImage path: artifacts @@ -308,7 +322,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout image - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: OpenRCT2/openrct2-docker - name: Build image @@ -321,20 +335,19 @@ jobs: OPENRCT2_BRANCH=$(echo "$GITHUB_REF" | sed 's/refs\/heads\///') echo "Current branch is $OPENRCT2_BRANCH" if [ "$OPENRCT2_BRANCH" = 'develop' ]; then - docker login -u "$OPENRCT2_DOCKER_USER" -p "$OPENRCT2_DOCKER_PASS" - docker push openrct2/openrct2-cli:develop + docker login -u "$OPENRCT2_DOCKER_USER" -p "$OPENRCT2_DOCKER_PASS" + docker push openrct2/openrct2-cli:develop else - echo 'Image not pushed' + echo 'Image not pushed' fi linux-clang: name: Linux (Debug, [http, network, OpenGL] disabled) using clang runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:0.3.1-bionic + container: openrct2/openrct2-build:0.3.1-bionic steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -345,11 +358,10 @@ jobs: name: Android runs-on: ubuntu-latest needs: check-code-formatting - container: - image: openrct2/openrct2-build:0.3.1-android + container: openrct2/openrct2-build:0.3.1-android steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: ccache uses: hendrikmuhs/ccache-action@v1 with: @@ -363,7 +375,7 @@ jobs: mkdir -p artifacts mv src/openrct2-android/app/build/outputs/apk/arm/pr/app-arm-pr.apk artifacts/openrct2-arm.apk - name: Upload artifacts (CI) - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: OpenRCT2-Android path: artifacts @@ -372,7 +384,7 @@ jobs: run: | . scripts/setenv -q if [[ "$OPENRCT2_PUSH" == "true" ]]; then - upload-build artifacts/openrct2-arm.apk android-arm $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH + upload-build artifacts/openrct2-arm.apk android-arm $OPENRCT2_VERSION $OPENRCT2_SHA1 $OPENRCT2_BRANCH else - echo 'Not going to push build' + echo 'Not going to push build' fi diff --git a/scripts/build b/scripts/build index 9274410488..fed96357ad 100755 --- a/scripts/build +++ b/scripts/build @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Ensure we are in root directory if [[ $(uname) == "Darwin" ]]; then @@ -10,7 +12,7 @@ cd $basedir if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then # Patch version.h - if [[ "$OPENRCT2_BUILD" != "" ]]; then + if [[ -n "$OPENRCT2_BUILD" ]]; then echo -e "\033[0;36mPatching version.h...\033[0m" fileversion=$OPENRCT2_VERSION.$OPENRCT2_BUILD productversion="$fileversion-${OPENRCT2_SHA1_SHORT}" diff --git a/scripts/build-appimage b/scripts/build-appimage index 0bc94c9a14..3e3b88c207 100755 --- a/scripts/build-appimage +++ b/scripts/build-appimage @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e echo -e "\033[0;36mBuilding AppImage for OpenRCT2...\033[0m" diff --git a/scripts/build-installer b/scripts/build-installer index 2f2fb5adff..bc18c336b4 100755 --- a/scripts/build-installer +++ b/scripts/build-installer @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -gt 2 || "$1" == "-h" ]]; then echo 'Create a Windows installer for OpenRCT2' @@ -17,7 +19,7 @@ if [[ "$1" == "-i" ]]; then fi basedir="$(readlink -f `dirname $0`/..)" -if [[ "$output" == "" ]]; then +if [[ -z "$output" ]]; then mkdir -p "$basedir/artifacts" output="$basedir/artifacts/openrct2-installer-$CONFIGURATION-$PLATFORM.exe" fi diff --git a/scripts/build-portable b/scripts/build-portable index bd4460cfa1..50b85d251e 100755 --- a/scripts/build-portable +++ b/scripts/build-portable @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]]; then # Create a Windows symbols archive for OpenRCT2 diff --git a/scripts/build-symbols b/scripts/build-symbols index 5fede436c6..8525cf83f1 100755 --- a/scripts/build-symbols +++ b/scripts/build-symbols @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Check 7z or zip is available if [ -x "$(command -v 7z)" ]; then diff --git a/scripts/check-code-formatting b/scripts/check-code-formatting index 86c2e64b22..823f811a37 100755 --- a/scripts/check-code-formatting +++ b/scripts/check-code-formatting @@ -1,8 +1,10 @@ -#!/bin/sh -e +#!/usr/bin/env sh + +set -e readlink_bin='readlink' -if [[ "$OSTYPE" == "darwin"* ]]; then +if [ "$(uname)" == "Darwin" ]; then if ! [ -x "$(command -v greadlink)" ]; then echo 'Please install greadlink with Homebrew: brew install coreutils' exit 1 diff --git a/scripts/create-macos-universal b/scripts/create-macos-universal index 2b8f94a412..185ccf6ff1 100755 --- a/scripts/create-macos-universal +++ b/scripts/create-macos-universal @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e echo "Creating macOS universal app bundle" # create app skeleton diff --git a/scripts/get-discord-rpc b/scripts/get-discord-rpc index cd785ff567..4e8ea55891 100755 --- a/scripts/get-discord-rpc +++ b/scripts/get-discord-rpc @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ $(uname) == "Linux" ]]; then basedir="$(readlink -f `dirname $0`/..)" diff --git a/scripts/install-nsis b/scripts/install-nsis index a31d6e3d18..0c815cd867 100755 --- a/scripts/install-nsis +++ b/scripts/install-nsis @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -ne 0 && "$#" -ne 2 ]]; then echo 'Install a portable version of NSIS which can build the OpenRCT2 Windows installer.' diff --git a/scripts/linux/build-appimage-docker.sh b/scripts/linux/build-appimage-docker.sh index cde760edf4..87bd3e3df8 100755 --- a/scripts/linux/build-appimage-docker.sh +++ b/scripts/linux/build-appimage-docker.sh @@ -1,10 +1,12 @@ -#!/bin/bash -ex +#!/usr/bin/env bash + +set -ex REPO_ROOT=$(readlink -f $(dirname "$0")/../..) docker run --rm -it -e NO_CLEANUP=1 -e CI=1 --device /dev/fuse:mrw -v $(readlink -f .):/ws openrct2/openrct2:ubuntu_amd64 bash -exc " cd /ws apt-get update -apt-get install -y wget libcairo2 +apt-get install -y libcairo2 scripts/linux/build-appimage.sh " diff --git a/scripts/linux/build-appimage.sh b/scripts/linux/build-appimage.sh index 6d2b1529c7..5c19b96d23 100755 --- a/scripts/linux/build-appimage.sh +++ b/scripts/linux/build-appimage.sh @@ -1,7 +1,9 @@ -#!/bin/bash -ex +#!/usr/bin/env bash + +set -ex # use RAM disk if possible -if [ "$CI" == "" ] && [ -d /dev/shm ]; then +if [ -z "$CI" ] && [ -d /dev/shm ]; then TEMP_BASE=/dev/shm else TEMP_BASE=/tmp @@ -15,7 +17,7 @@ cleanup () { fi } -if [ "$NO_CLEANUP" == "" ] && trap cleanup EXIT +if [ -z "$NO_CLEANUP" ] && trap cleanup EXIT # store repo root as variable REPO_ROOT=$(readlink -f $(dirname "$0")/../..) @@ -32,7 +34,7 @@ cmake "$REPO_ROOT" -DCMAKE_INSTALL_PREFIX=/usr -G Ninja -DCMAKE_BUILD_TYPE=Relea ninja -k0 DESTDIR=AppDir ninja install -wget https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage +curl -fLO https://github.com/TheAssassin/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage chmod +x linuxdeploy*.AppImage ./linuxdeploy*.AppImage --appimage-extract-and-run --appdir AppDir/ --output appimage diff --git a/scripts/run-testpaint b/scripts/run-testpaint index de0968afc3..9f5cc22a88 100755 --- a/scripts/run-testpaint +++ b/scripts/run-testpaint @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Ensure we are in root directory basedir="$(readlink -f `dirname $0`/..)" diff --git a/scripts/run-tests b/scripts/run-tests index e02f7d926b..ec0bd8adbc 100755 --- a/scripts/run-tests +++ b/scripts/run-tests @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e # Ensure we are in root directory if [[ $(uname) == "Darwin" ]]; then diff --git a/scripts/setenv b/scripts/setenv index bfbeb369e6..bb47c00a9f 100755 --- a/scripts/setenv +++ b/scripts/setenv @@ -1,4 +1,6 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -e # This sets up more environment variables using the existing environment # It should be dot sourced into your environment @@ -34,13 +36,13 @@ else export OPENRCT2_PUSH=true fi fi -if [[ "$OPENRCT2_ORG_TOKEN" == "" ]]; then +if [[ -z "$OPENRCT2_ORG_TOKEN" ]]; then unset OPENRCT2_PUSH fi # Get the short SHA1 export OPENRCT2_SHA1=$GITHUB_SHA -export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1:0:7} +export OPENRCT2_SHA1_SHORT=${OPENRCT2_SHA1::7} unset OPENRCT2_VERSION_EXTRA if [[ "$OPENRCT2_TAG" != "true" ]]; then export OPENRCT2_VERSION_EXTRA=$OPENRCT2_BRANCH-$OPENRCT2_SHA1_SHORT diff --git a/scripts/upload-backtrace-symbols b/scripts/upload-backtrace-symbols index b4c5afefe7..8022d3a843 100755 --- a/scripts/upload-backtrace-symbols +++ b/scripts/upload-backtrace-symbols @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -ne 1 ]]; then echo 'Upload OpenRCT2 debug symbols to https://backtrace.io.' @@ -11,7 +13,7 @@ fi path=$1 -if [ "$BACKTRACE_IO_TOKEN" == "" ]; then +if [ -z "$BACKTRACE_IO_TOKEN" ]; then echo -e "\033[0;31mBACKTRACE_IO_TOKEN not set" exit 1 fi diff --git a/scripts/upload-build b/scripts/upload-build index 76e9cf5e3a..3bfda7edde 100755 --- a/scripts/upload-build +++ b/scripts/upload-build @@ -1,4 +1,6 @@ -#!/bin/bash -e +#!/usr/bin/env bash + +set -e if [[ "$#" -ne 4 && "$#" -ne 5 ]]; then echo 'Upload an OpenRCT2 build to openrct2.org.' @@ -71,13 +73,13 @@ case "$flavour" in exit 1 esac -if [ "$branch" != "" ]; then - versionextra=-$branch-${sha1:0:7} +if [ -n "$branch" ]; then + versionextra=-$branch-${sha1::7} fi filename=OpenRCT2-$version$versionextra-$flavour echo -e "\033[0;36mUploading to openrct2.org as '$filename'..." -if [ "$OPENRCT2_ORG_TOKEN" == "" ]; then +if [ -z "$OPENRCT2_ORG_TOKEN" ]; then echo -e "\033[0;31mOPENRCT2_ORG_TOKEN not set" exit 1 fi diff --git a/scripts/vstool b/scripts/vstool index e96d4cf708..c1d46e7054 100755 --- a/scripts/vstool +++ b/scripts/vstool @@ -1,3 +1,5 @@ -#!/bin/bash +#!/usr/bin/env bash + +set -e vstool.cmd $@ diff --git a/src/openrct2-android/gradlew b/src/openrct2-android/gradlew index 9d82f78915..14d3e67fd5 100755 --- a/src/openrct2-android/gradlew +++ b/src/openrct2-android/gradlew @@ -120,7 +120,7 @@ if $cygwin ; then done OURCYGPATTERN="(^($ROOTDIRS))" # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then + if [ -n "$GRADLE_CYGPATTERN" ] ; then OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" fi # Now convert the arguments - kludge to limit ourselves to /bin/sh