Skip to content

build: remove hard-coded build setup #227

build: remove hard-coded build setup

build: remove hard-coded build setup #227

Workflow file for this run

name: 'Build'
on:
push:
branches: '**'
pull_request:
branches: 'main'
workflow_call:
# workflow_dispatch:
# inputs:
# verbose_build:
# description: 'verbose build process'
# type: boolean
# required: true
# default: false
permissions:
contents: read
jobs:
build:
name: 'Build & Test'
strategy:
fail-fast: false
matrix:
os:
- ubuntu-22.04
- ubuntu-20.04
- macos-12
- macos-11
dc:
- dmd-latest
- ldc-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dlang-community/setup-dlang@v1
with:
compiler: ${{ matrix.dc }}
- name: 'Cache dub packages'
uses: actions/cache@v4
with:
path: |
~/.dub
key: dub-packages-${{ matrix.os }}-${{ matrix.dc }}-${{ hashFiles('dub.selections.json') }}
- name: 'dub build/lint/test'
run: |
echo "::group::Build info:"
if [[ -x /usr/bin/xcodebuild ]]; then
xcode_version_raw="$(/usr/bin/xcodebuild -version)"
xcode_version="$(echo "$xcode_version_raw" | awk '/Xcode/ { print int($2) }')"
if [[ $xcode_version -eq 15 ]]; then
# https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Known-Issues
export DFLAGS="-L-ld_classic"
fi
echo "::notice title=${{ matrix.os }} Xcode version::$xcode_version_raw"
fi
compiler_version="$($DC --version)"
echo "::notice title=${{ matrix.os }}/${{ matrix.dc }} compiler::$compiler_version"
echo "::endgroup::"
dub build --compiler=$DC --build=release-debug # --verbose
dub lint --compiler=$DC # --verbose
dub test --compiler=$DC --coverage # --verbose
- name: 'Upload binary'
uses: actions/upload-artifact@v4
with:
name: myrc-${{ matrix.os }}-${{ matrix.dc }}
path: myrc
retention-days: 14
- name: 'Upload coverage'
uses: actions/upload-artifact@v4
with:
name: coverage_${{ matrix.os }}_${{ matrix.dc }}
path: '*.lst'
retention-days: 14
summary-report:
name: 'Tests report'
needs: build
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: coverage*
- name: 'Generate coverage summary'
run: |
s="### Tests coverage\n\n"
for dir in $(ls -1d coverage_*); do
IFS='_' read -ra title <<< "$dir"
s+="#### ${title[1]} - ${title[2]}\n\n"
s+="<details>\n\n"
declare -A coverage_per_file
eval $(awk '/covered/ { split($1,f,/\//); print "coverage_per_file["f[2]"]="int($3) }' $dir/*.lst)
declare -i coverage=0
for v in "${coverage_per_file[@]}"; do coverage+=$v; done
coverage=$(($coverage/${#coverage_per_file[@]}))
s+="<summary>$coverage%</summary>\n\n"
s+="| File | Coverage |\n"
s+="| --- | --- |\n"
for k in "${!coverage_per_file[@]}"; do
s+="| $k | ${coverage_per_file[$k]}% |\n"
done
s+="\n</details>\n\n"
done
echo -e "$s"
echo -e "$s" >> $GITHUB_STEP_SUMMARY