Skip to content

Commit

Permalink
Build (cmake) and CI/CD updates (otland#2973)
Browse files Browse the repository at this point in the history
* cmake is upgraded and related configs modified
* build using cmake on Windows (with vcpkg) is now possible
* cotire is not used when redundant (cmake >= 3.16)
* Lua version shown on startup
* Github Actions
  • Loading branch information
DSpeichert authored May 3, 2020
1 parent c29b913 commit 4233f74
Show file tree
Hide file tree
Showing 25 changed files with 1,260 additions and 726 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build on Ubuntu

on:
push:
branches:
- master
- v*

tags:
- v*

paths:
- cmake/**
- src/**
- CMakeLists.txt

pull_request:
paths:
- cmake/**
- src/**
- CMakeLists.txt

jobs:
build-ubuntu:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: >
sudo apt-get install git cmake build-essential libluajit-5.1-dev libmysqlclient-dev
libboost-date-time-dev libboost-system-dev libboost-iostreams-dev libboost-filesystem-dev
libpugixml-dev libcrypto++-dev
- name: Build with cmake
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ runner.workspace }}/build
# will set the CC & CXX for cmake
cc: gcc
cxx: g++
build-type: Release
# Extra options pass to cmake while configuring project
configure-options: -DUSE_LUAJIT=on
# run build using '-j [parallel]' to use multiple threads to build
parallel: 2

- name: Upload binary
uses: actions/upload-artifact@v2
with:
name: ubuntu-tfs-amd64-${{ github.sha }}
path: ${{ runner.workspace }}/build/tfs
126 changes: 126 additions & 0 deletions .github/workflows/build-vcpkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: Build with vcpkg

on:
push:
branches:
- master
- v*

tags:
- v*

paths:
- cmake/**
- src/**
- CMakeLists.txt

pull_request:
paths:
- cmake/**
- src/**
- CMakeLists.txt

jobs:
job:
name: ${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
max-parallel: 8
matrix:
os: [ubuntu, windows, macos]
buildtype: [Debug, Release]
luajit: [on, off]
include:
- os: windows
triplet: x64-windows
packages: >
boost-asio boost-iostreams boost-system boost-filesystem boost-variant boost-lockfree
lua luajit libmariadb pugixml cryptopp
- os: ubuntu
triplet: x64-linux
packages: >
boost-asio boost-iostreams boost-system boost-filesystem boost-variant boost-lockfree
lua libmariadb pugixml cryptopp
- os: macos
triplet: x64-osx
packages: >
boost-asio boost-iostreams boost-system boost-filesystem boost-variant boost-lockfree
lua libmariadb pugixml cryptopp
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Unshallow
run: git fetch --prune --unshallow

- name: Get latest CMake
# Using 'latest' branch, the latest CMake is installed.
uses: lukka/get-cmake@latest

- name: Ubuntu - install luajit, remove libmysqlclient-dev
run: |
sudo apt-get install libluajit-5.1-dev
sudo apt-get remove -y libmysqlclient-dev
if: contains( matrix.os, 'ubuntu')

- name: MacOS - install luajit pkgconfig
run: brew install luajit pkgconfig
if: contains( matrix.os, 'macos')

- name: Windows - remove C:/mysql*
run: rm -r -fo C:/mysql-5.7.21-winx64
if: contains( matrix.os, 'windows')

- name: Run vcpkg
uses: lukka/run-vcpkg@v2
with:
vcpkgArguments: ${{ matrix.packages }}
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
vcpkgTriplet: ${{ matrix.triplet }}
vcpkgGitCommitId: c444db5f5a954bd53c8dad004cee39c4064d844e

- name: Build with CMake
uses: lukka/run-cmake@v2
with:
useVcpkgToolchainFile: true
buildDirectory: ${{ runner.workspace }}/build
cmakeBuildType: ${{ matrix.buildtype }}
cmakeAppendedArgs: -DUSE_LUAJIT=${{ matrix.luajit }}

- name: dir
run: find $RUNNER_WORKSPACE
shell: bash

- name: Upload artifact binary
uses: actions/upload-artifact@v2
with:
name: tfs-${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: ${{ runner.workspace }}/build/tfs
if: "! contains( matrix.os, 'windows')"

- name: Upload artifact binary (exe)
uses: actions/upload-artifact@v2
with:
name: tfs-${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: ${{ runner.workspace }}/build/tfs.exe
if: contains( matrix.os, 'windows')

- name: Upload artifact binary (dlls)
uses: actions/upload-artifact@v2
with:
name: tfs-${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: ${{ runner.workspace }}/build/*.dll
if: contains( matrix.os, 'windows')

- name: Prepare datapack contents
run: find . -maxdepth 1 ! -name data ! -name config.lua.dist ! -name key.pem ! -name LICENSE ! -name README.md ! -name schema.sql -exec rm -r {} \;
shell: bash

- name: Upload datapack contents
uses: actions/upload-artifact@v2
with:
name: tfs-${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }}-${{ github.sha }}
path: ${{ github.workspace }}
63 changes: 63 additions & 0 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Coverity
on:
repository_dispatch:
types: coverity_scan
schedule:
- cron: '0 0 * * 5' # Weekly at 00:00 UTC

env:
COVERITY_PROJECT: otland/forgottenserver
COVERITY_EMAIL: [email protected]

jobs:
scan:
runs-on: ubuntu-latest
if: github.repository == 'otland/forgottenserver'
steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: >
sudo apt-get install git cmake build-essential libluajit-5.1-dev libgmp3-dev libmysqlclient-dev
libboost-date-time-dev libboost-system-dev libboost-iostreams-dev libboost-filesystem-dev
libpugixml-dev libcrypto++-dev
- name: Get latest CMake
# Using 'latest' branch, the latest CMake is installed.
uses: lukka/get-cmake@latest

- name: Download Coverity Build Tool
run: |
cd ${{ runner.workspace }}
wget -q https://scan.coverity.com/download/cxx/linux64 --post-data "token=$TOKEN&project=$COVERITY_PROJECT" -O cov-analysis-linux64.tar.gz
mkdir cov-analysis-linux64
tar xzf cov-analysis-linux64.tar.gz --strip 1 -C cov-analysis-linux64
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}

- name: Prepare build
run: |
mkdir build
cd build
cmake ..
- name: Build with cov-build
run: |
export PATH=${{ runner.workspace }}/cov-analysis-linux64/bin:$PATH
cd build
cov-build --dir ${{ runner.workspace }}/cov-int make -j2
- name: Submit the result to Coverity Scan
run: |
cd ${{ runner.workspace }}
tar czvf forgottenserver.tgz cov-int
du -hs forgottenserver.tgz
curl \
--form project=$COVERITY_PROJECT \
--form token=$TOKEN \
--form email=$COVERITY_EMAIL \
--form [email protected] \
--form version=$GITHUB_SHA \
https://scan.coverity.com/builds?project=$COVERITY_PROJECT
env:
TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
jobs:
# Push image to GitHub Package Registry.
# See also https://docs.docker.com/docker-hub/builds/
push:
docker-image:
runs-on: ubuntu-latest
if: github.event_name == 'push'

Expand All @@ -31,7 +31,7 @@ jobs:

- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
IMAGE_ID=$(echo "docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME" | awk '{print tolower($0)}')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/lua-syntax.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
name: Lua syntax check

on: [pull_request]
on:
pull_request:
paths:
- data/**.lua
push:
paths:
- data/**.lua

jobs:
build:

luac:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2

- uses: leafo/gh-actions-lua@v5
- uses: leafo/gh-actions-lua@v5

- name: Test Lua syntax
run: find data/ -name '*.lua' -print0 | xargs -0 -n1 luac -p
- name: Test Lua syntax
run: find data/ -name '*.lua' -print0 | xargs -0 -n1 luac -p
21 changes: 21 additions & 0 deletions .github/workflows/xml-syntax.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: XML syntax check

on:
pull_request:
paths:
- data/**.xml
push:
paths:
- data/**.xml

jobs:
luac:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install xmllint
run: apt-get install -y libxml2-utils

- name: Test XML syntax
run: find data/ -name '*.xml' -print0 | xargs -0 -n1 xmllint --noout
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*.suo
*.user
*.sln.docstates
.idea/
.vscode/

# Build results
Expand All @@ -19,6 +20,7 @@ x64/
build/
[Bb]in/
[Oo]bj/
cmake-build-*/

# MSTest test Results
[Tt]est[Rr]esult*/
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cache: apt
addons:
apt:
packages:
- libboost-dev
- libboost-date-time-dev
- libboost-system-dev
- libboost-filesystem-dev
- libboost-iostreams-dev
Expand Down
Loading

0 comments on commit 4233f74

Please sign in to comment.