CI fix #80
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Harrison Ford (@hatf0) | |
# This CI file has been heavily based off of my work in the Mir project. | |
name: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
# allow this workflow to be triggered manually | |
# Only allow for one job from each actor to run at a time, and cancel any jobs currently in progress. | |
concurrency: | |
group: gh-actions-${{ github.actor }}-${{ github.head_ref }} | |
cancel-in-progress: true | |
jobs: | |
setup: | |
name: 'Load job configuration' | |
runs-on: ubuntu-20.04 | |
outputs: | |
compilers: ${{ steps.load-config.outputs.compilers }} | |
steps: | |
- uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 | |
# This step checks if we want to skip CI entirely, then outputs the compilers to be used for | |
# each job. A little overkill, as we don't intend to support multiple platforms, but I digress. | |
- id: load-config | |
uses: actions/github-script@9ac08808f993958e9de277fe43a64532a609130e | |
with: | |
script: | | |
const base_compiler_config = require("./.github/workflows/compilers.json"); | |
let compilers = []; | |
const {owner, repo} = context.repo; | |
let commit_sha = context.sha; | |
if (context.eventName == "pull_request") | |
{ | |
commit_sha = context.payload.pull_request.head.sha; | |
} | |
const commit = await github.rest.git.getCommit({ | |
owner, | |
repo, | |
commit_sha | |
}); | |
const head_commit_message = commit.data.message; | |
if (!head_commit_message.startsWith("[skip-ci]")) | |
{ | |
compilers = base_compiler_config; | |
} | |
core.setOutput("compilers", JSON.stringify(compilers)); | |
ci: | |
name: '[ci] ${{ matrix.dc }}/${{ matrix.build }}-${{ matrix.stat_type }}' | |
runs-on: ubuntu-20.04 | |
needs: setup | |
# Only run if the setup phase explicitly defined compilers to be used | |
if: ${{ fromJSON(needs.setup.outputs.compilers) != '' && fromJSON(needs.setup.outputs.compilers) != '[]' }} | |
# Beta / master versions of any compiler are allowed to fail | |
continue-on-error: ${{ contains(matrix.dc, 'beta') || contains(matrix.dc, 'master') }} | |
env: | |
BUILD: ${{ matrix.build }} | |
STAT_TYPE: ${{ matrix.stat_type }} | |
CONN_STRING: "host=localhost port=5432 dbname=postgres password=postgres user=postgres" | |
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 5432:5432 | |
strategy: | |
fail-fast: false | |
matrix: | |
build: [unittest, release] | |
stat_type: [static, dynamic, dynamic-unmanaged] | |
dc: ${{ fromJSON(needs.setup.outputs.compilers) }} | |
include: | |
- build: unittest-cov | |
dc: dmd-latest | |
stat_type: none | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 | |
- name: Setup D compiler | |
uses: dlang-community/setup-dlang@763d869b4d67e50c3ccd142108c8bca2da9df166 | |
with: | |
compiler: ${{ matrix.dc }} | |
- name: Install dependencies | |
run: sudo apt-get -y update && sudo apt-get -y install libpq-dev libevent-dev libcurl4-gnutls-dev postgresql | |
- name: Cache dub dependencies | |
uses: actions/cache@937d24475381cd9c75ae6db12cb4e79714b926ed | |
with: | |
path: ~/.dub/packages | |
key: ubuntu-latest-build-${{ hashFiles('**/dub.sdl', '**/dub.json') }} | |
restore-keys: | | |
ubuntu-latest-build- | |
- name: Install dub dependencies | |
run: | | |
dub fetch dscanner | |
dub fetch doveralls | |
shell: bash | |
- name: Build / test | |
if: matrix.build != 'unittest-cov' | |
run: | | |
dub run dpq2:integration_tests --build=$BUILD --config=$STAT_TYPE -- --conninfo="$CONN_STRING" | |
shell: bash | |
- name: Build / test with coverage | |
if: matrix.build == 'unittest-cov' | |
run: | | |
dub run dpq2:integration_tests --build=unittest-cov -- --conninfo="$CONN_STRING" | |
dub run dpq2:example --build=release -- --conninfo="$CONN_STRING" | |
dub run doveralls | |
shell: bash | |
- name: Upload coverage data | |
if: matrix.build == 'unittest-cov' | |
uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b | |