Skip to content

Build Engine (Docker) #532

Build Engine (Docker)

Build Engine (Docker) #532

Workflow file for this run

name: Build Engine (Docker)
on:
workflow_dispatch:
inputs:
strip-symbols:
description: Strip Debug Symbols
required: true
default: 'true'
use-caches:
description: Use Caches (Docker/ccache)
required: true
default: 'true'
archtune-flags:
description: Arch/Tune Flags
required: false
default: ''
buildtype:
type: choice
description: Build Type
required: false
options:
- RELWITHDEBINFO
- DEBUG
- RELEASE
- PROFILE
default: 'RELWITHDEBINFO'
buildtype-flags:
description: Build Type Compilation Flags Override
required: false
default: ''
compilation-flags:
description: Extra Compilation Flags
required: false
default: ''
clean-ccache:
description: Reset ccache before build
required: false
default: 'false'
debug-tmate:
description: Debug with tmate (either "pre" or "post" Docker run)
required: false
default: 'false'
debug-ccache:
description: Generate ccache Debug Artifacts
required: false
default: 'false'
docker-image:
description: 'Docker Image to use (Docker Hub name or "*" to used embedded image)'
required: false
default: '*'
#default: 'verybadsoldier/springrts-build:dbg'
jobs:
build_engine:
name: ${{ matrix.config.os }}
runs-on: ${{ matrix.config.runs-on }}
strategy:
fail-fast: true
matrix:
config:
- {
os: 'windows-64',
runs-on: 'ubuntu-latest'
}
- {
os: 'linux-64',
runs-on: 'ubuntu-latest'
}
steps:
- name: Install pigz
run: |
sudo apt-get update
sudo apt-get install pigz
- name: Extract Branch Name
#https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions/58034787
id: extract-branch
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
shell: bash
- name: Print Build Info
run: |
echo "Build info:"
echo "Git commit hash: ${{ github.sha }}"
echo "Repository: ${{ github.repository }}"
df -h
shell: bash
- name: Checkout Source Repository
uses: actions/checkout@v3
- name: Get Random Number
id: get-random-number
run: |
number=$(head /dev/random -c 32 | sha1sum | awk '{ print $1 }')
echo "Generated random number: $number"
echo "number=${number}" >> "$GITHUB_OUTPUT"
shell: bash
- name: Download ccache Data
if: github.event.inputs.use-caches == 'true'
id: cache-dl
uses: actions/cache@v3
with:
path: /tmp/ccache_archive
key: ccache-${{ matrix.config.os }}-${{ steps.get-random-number.outputs.number }}
restore-keys: |
ccache-${{ matrix.config.os }}-
- name: Check and unpack ccache Data
id: cache
run: |
CACHE_FILENAME="/tmp/ccache_archive/${{ matrix.config.os }}.tgz"
echo "cache-filename=${CACHE_FILENAME}" >> "$GITHUB_OUTPUT"
if [ -f "${CACHE_FILENAME}" ]; then
echo "Found build ccache: ${CACHE_FILENAME}"
if [ "${{ github.event.inputs.clean-ccache }}" == "true" ]; then
echo "Deleting ccache: ${CACHE_FILENAME}"
rm -rf "${CACHE_FILENAME}"
else
echo "cache-hit=true" >> "$GITHUB_OUTPUT"
echo "Extracting..."
mkdir -p /tmp/ccache
tar -I pigz -xf "${CACHE_FILENAME}" -C /tmp/ccache
fi
else
echo "Not found ccache data"
echo "cache-hit=false" >> "$GITHUB_OUTPUT"
fi
df -h
shell: bash
- name: Build engine via docker
uses: ./docker-build
id: run-docker-build
with:
archtune-flags: "${{ github.event.inputs.archtune-flags }}"
buildtype: "${{ github.event.inputs.buildtype }}"
buildtype-flags: "${{ github.event.inputs.buildtype-flags }}"
compilation-flags: "${{ github.event.inputs.compilation-flags }}"
use-cache: "${{ github.event.inputs.use-caches }}"
platform: "${{ matrix.config.os }}"
branch: "${{ env.BRANCH_NAME }}"
repository-url: "https://github.com/${{ github.repository }}"
debug-tmate: "${{ github.event.inputs.debug-tmate }}"
debug-ccache: "${{ github.event.inputs.debug-ccache }}"
docker-image: "${{ github.event.inputs.docker-image }}"
- name: Upload Bin as Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ steps.run-docker-build.outputs.bin_name }}
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.bin_name }}
if-no-files-found: error
- name: Upload Dbg Artifacts
if: github.event.inputs.strip-symbols == 'true'
uses: actions/upload-artifact@v3
with:
name: ${{ steps.run-docker-build.outputs.dbg_name }}
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.dbg_name }}
if-no-files-found: error
- name: Upload Build Options Artifact
uses: actions/upload-artifact@v3
with:
name: buildoptions_${{ matrix.config.os }}.txt
path: ${{ github.workspace }}/artifacts/buildoptions_${{ matrix.config.os }}.txt
if-no-files-found: error
- name: Pack ccache Data
if: github.event.inputs.use-caches == 'true'
run: |
CACHE_FILENAME="${{ steps.cache.outputs.cache-filename }}"
echo "Creating cache file: ${CACHE_FILENAME}"
mkdir -p /tmp/ccache_archive
rm -rf /tmp/ccache_archive/*
tar cvf - -C /tmp/ccache . 2> /dev/null | pigz -1 > "${CACHE_FILENAME}"
echo "Raw ccache size: $(du -sch /tmp/ccache | tail -n1 | cut -f1)"
echo "Archived ccache size: $(du -h "${CACHE_FILENAME}" | cut -f1)"
- name: Upload ccache Debug Data
uses: actions/upload-artifact@v3
if: github.event.inputs.debug-ccache == 'true'
with:
name: ccache_debug_${{ matrix.config.os }}.tgz
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.ccache_dbg }}
if-no-files-found: error
- name: Free Filesystem Space
id: freefsspace
run: |
echo "Filesystem before cleanup:"
df -h
docker system df
echo "Pruning docker images..."
docker image prune -a -f
echo "Filesystem after cleanup:"
df -h
docker system df
shell: bash