Github Actions enhancements

This commit is contained in:
Tyler Wilding
2020-10-09 21:08:16 -04:00
parent adc09d7c79
commit a5972e5111
5 changed files with 244 additions and 84 deletions
+8
View File
@@ -0,0 +1,8 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
+29
View File
@@ -0,0 +1,29 @@
name: Linter
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
lint:
name: Linting & Formatting
runs-on: ubuntu-20.04
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 10
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Get Package Dependencies
run: sudo apt install clang-format clang-tidy
- name: Check Clang-Formatting
run: |
chmod +x ./third-party/run-clang-format/run-clang-format.py
./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test --color always
+114
View File
@@ -0,0 +1,114 @@
name: Linux
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
strategy:
# Prevent one build from failing everything (although maybe those should be included as experimental builds instead)
fail-fast: false
matrix:
os: [ubuntu-20.04]
config: [Debug] # TODO - Eventually we need to make a Release Config
experimental: [false]
name: ${{ matrix.config }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 10
steps:
# NOTE - useful for debugging
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"
- name: Checkout Repository
uses: actions/checkout@v2
- name: Cache Submodules
id: cache-submodules
uses: actions/cache@v2
with:
key: submodules-${{ hashFiles('./.gitmodules') }}
path: |
./third-party/googletest
./third-party/spdlog
./.git/modules/
- name: Checkout Submodules
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: git submodule update --init --recursive --jobs 2
- name: Prepare Artifact Git Info
shell: bash
run: |
echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
ARTIFACT_NAME="commit-$(git rev-parse --short "$GITHUB_SHA")"
if [ ${{ github.event_name == 'pull_request' }} ]; then
echo "##[set-output name=short-sha;]$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
if [ ! -z "${{ github.event.pull_request.number }}" ]; then
ARTIFACT_NAME="pr-${{ github.event.pull_request.number }}-commit-$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
fi
else
echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")"
fi
echo "##[set-output name=artifact-metadata;]${ARTIFACT_NAME}"
id: git-vars
- name: Get Package Dependencies
run: sudo apt install build-essential cmake ccache gcc g++ lcov make nasm
# -- SETUP CCACHE - https://cristianadam.eu/20200113/speeding-up-c-plus-plus-github-actions-using-ccache/
- name: Prepare ccache timestamp
id: ccache_cache_timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: ccache cache files
uses: actions/cache@v2
with:
path: .ccache
key: ${{ matrix.config }}-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }}
restore-keys: |
${{ matrix.config }}-ccache-
- name: CMake Generation
run: cmake -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -B build -DCODE_COVERAGE=ON
- name: Build Project
working-directory: ./build
env:
CCACHE_BASEDIR: ${GITHUB_WORKSPACE}
CCACHE_DIR: ${GITHUB_WORKSPACE}/.ccache
CCACHE_COMPRESS: "true"
CCACHE_COMPRESSLEVEL: "6"
CCACHE_MAXSIZE: "400M"
run: |
ccache -p
ccache -z
make -j4
ccache -s
- name: Run Tests
run: ./test_code_coverage.sh
- name: Coveralls
uses: coverallsapp/github-action@master
continue-on-error: true # Sometimes Coveralls has intermittent problems, and codecoverage isn't critical to our success
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/goalc-test_coverage.info
+93
View File
@@ -0,0 +1,93 @@
name: Windows
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build:
strategy:
# Prevent one build from failing everything (although maybe those should be included as experimental builds instead)
fail-fast: false
matrix:
os: [windows-2019]
config: [Debug] # TODO - Eventually we need to make a Release Config
experimental: [false]
name: ${{ matrix.config }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
# Set some sort of timeout in the event of run-away builds. We are limited on concurrent jobs so, get rid of them.
timeout-minutes: 10
steps:
# NOTE - useful for debugging
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo "$GITHUB_CONTEXT"
- name: Checkout Repository
uses: actions/checkout@v2
- name: Cache Submodules
id: cache-submodules
uses: actions/cache@v2
with:
key: submodules-${{ hashFiles('./.gitmodules') }}
path: |
./third-party/googletest
./third-party/spdlog
./.git/modules/
- name: Checkout Submodules
if: steps.cache-submodules.outputs.cache-hit != 'true'
run: git submodule update --init --recursive --jobs 2
- name: Prepare Artifact Git Info
shell: bash
run: |
echo "##[set-output name=branch;]${GITHUB_REF#refs/heads/}"
ARTIFACT_NAME="commit-$(git rev-parse --short "$GITHUB_SHA")"
if [ ${{ github.event_name == 'pull_request' }} ]; then
echo "##[set-output name=short-sha;]$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
if [ ! -z "${{ github.event.pull_request.number }}" ]; then
ARTIFACT_NAME="pr-${{ github.event.pull_request.number }}-commit-$(git rev-parse --short "${{ github.event.pull_request.head.sha }}")"
fi
else
echo "##[set-output name=short-sha;]$(git rev-parse --short "$GITHUB_SHA")"
fi
echo "##[set-output name=artifact-metadata;]${ARTIFACT_NAME}"
id: git-vars
# https://github.com/ilammy/setup-nasm
- uses: ilammy/setup-nasm@v1
- name: CMake Generation
shell: cmd # ideally id like everything to be powershell but running this bat file is finicky
run: |
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
cmake --version
cmake -B build -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" .
- name: Build Project
working-directory: ./build
shell: cmd
run: |
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
set CL=/MP
nmake
- name: Run Tests
timeout-minutes: 5
run: |
$env:NEXT_DIR = $pwd
$env:FAKE_ISO_PATH = "/game/fake_iso.txt"
./build/bin/goalc-test.exe --gtest_color=yes
-84
View File
@@ -1,84 +0,0 @@
name: Build
on: [push, pull_request]
jobs:
common:
# TODO - Start using clang-tidy - requires a bit more setup though - http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
name: Linting & Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
submodules: true
- name: Get Package Dependencies
run: sudo apt install clang-format clang-tidy
- name: Check Clang-Formatting
run: |
chmod +x ./third-party/run-clang-format/run-clang-format.py
./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test --color always
build-linux:
name: (Linux) Build & Test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
working-directory: ./
steps:
- name: Checkout Repository
uses: actions/checkout@v1
with:
submodules: true
- name: Get Package Dependencies
run: sudo apt install build-essential cmake gcc g++ lcov make nasm
- name: CMake Generation
run: |
cmake --version
cmake -B build -DCODE_COVERAGE=ON
- name: Build Project
run: |
cd build
make -j4
- name: Run Tests
timeout-minutes: 5
run: ./test_code_coverage.sh
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: ./build/goalc-test_coverage.info
build-windows:
# Very good resource - https://cristianadam.eu/20191222/using-github-actions-with-c-plus-plus-and-cmake/
name: (Windows) Build & Test
runs-on: windows-latest
defaults:
run:
shell: powershell
working-directory: ./
steps:
- name: Checkout Repository
uses: actions/checkout@v1
with:
submodules: true
# https://github.com/ilammy/setup-nasm
- uses: ilammy/setup-nasm@v1
# TODO - we need to make a release configuration! (i think linux needs one too)
- name: CMake Generation
shell: cmd # ideally id like everything to be powershell but running this bat file is finicky
run: |
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
cmake --version
cmake -B build -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" .
- name: Build Project
working-directory: ./build
shell: cmd
run: |
call "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Auxiliary/Build/vcvars64.bat"
set CL=/MP
nmake
- name: Run Tests
timeout-minutes: 5
run: |
$env:NEXT_DIR = $pwd
$env:FAKE_ISO_PATH = "/game/fake_iso.txt"
./build/bin/goalc-test.exe --gtest_color=yes