ci: replace push, pull workflows with main

This commit is contained in:
Simon Michael 2022-04-25 00:16:44 -10:00
parent c2bc7dfb83
commit 75f87439e2
2 changed files with 77 additions and 312 deletions

View File

@ -1,46 +1,49 @@
# Runs after notable pushes to pull requests against master. # The main hledger integration test workflow.
# master is configured to require one or more status checks corresponding to # Builds warning free and runs unit/doc/functional/haddock/bench tests,
# enabled matrix plans below (shown in github UI as "build (810, ...").
# So those must pass before the pull request can be merged.
#
# Runs unit/doc/functional/haddock/bench tests and produces optimised dynamic x64 linux binaries,
# using the GHC version(s) enabled below. # using the GHC version(s) enabled below.
# # Merging to master requires that this workflow's jobs ("86" at least) have passed.
# This was our first github workflow, and may have the most detailed notes.
name: pull request CI name: main CI
# This workflow runs...
on: on:
# Scheduled workflows run on the latest commit on the default or base branch. (master) # on master, when manually triggered
workflow_dispatch:
# on master, on this schedule:
# schedule: # schedule:
# - cron: "0 07 * * 0" # sunday midnight pacific # - cron: "0 07 * * 0" # sunday midnight pacific
# on these dev branches, when pushed
push:
branches: [ simon, simon2 ]
# on pull request branches against these branches, when pushed
pull_request: pull_request:
branches: [ master ] branches: [ master ]
paths: # Uncomment to run it only for changes to these paths: (but that could prevent merging)
- '.github/workflows/linux.yml' # paths:
- 'stack*.yaml' # - '.github/workflows/pushpull.yml'
- 'hledger-lib/**' # - 'stack*.yaml'
- 'hledger/**' # - 'hledger-lib/**'
- 'hledger-ui/**' # - 'hledger/**'
- 'hledger-web/**' # - 'hledger-ui/**'
- 'bin/*.hs' # - 'hledger-web/**'
# ignore changes to example files, though currently some func tests depend on them # - 'bin/*.hs'
- 'examples/**' # - 'examples/**'
- '!**.journal' # Or to ignore certain paths:
- '!**.j' # # examples
- '!**.ledger' # - '!**.journal'
- '!**.csv' # - '!**.j'
# ignore changes to doc source files # - '!**.ledger'
- '!**.m4' # - '!**.csv'
- '!**.md' # # docs
- '!**.1' # - '!**.m4'
- '!**.5' # - '!**.md'
- '!**.info' # - '!**.1'
- '!**.txt' # - '!**.5'
# - '!**.info'
# also allow this workflow to be triggered manually # - '!**.txt'
workflow_dispatch:
jobs: jobs:
build: build:
@ -49,11 +52,11 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
plan: # at least the check(s) required by master should be enabled plan: # at least the check(s) required by master should be enabled
- { ghc: "86" , stack: "stack --stack-yaml=stack8.6.yaml" } - { ghc: "86" , stack: "stack --stack-yaml=stack8.6.yaml" } # oldest supported ghc
# - { ghc: "88" , stack: "stack --stack-yaml=stack8.8.yaml" } # - { ghc: "88" , stack: "stack --stack-yaml=stack8.8.yaml" }
# - { ghc: "810", stack: "stack --stack-yaml=stack8.10.yaml" } # - { ghc: "810", stack: "stack --stack-yaml=stack8.10.yaml" }
# - { ghc: "90" , stack: "stack --stack-yaml=stack.yaml" } # - { ghc: "90" , stack: "stack --stack-yaml=stack.yaml" }
# - { ghc: "92" , stack: "stack --stack-yaml=stack9.2.yaml" } # - { ghc: "92" , stack: "stack --stack-yaml=stack9.2.yaml" } # newest supported ghc
steps: steps:
@ -61,14 +64,13 @@ jobs:
uses: actions/checkout@v2 uses: actions/checkout@v2
# have to fetch everything for git describe for --version # have to fetch everything for git describe for --version
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Print debug output - name: Print debug output
env: env:
GITHUB_CONTEXT: ${{ toJson(github) }} GITHUB_CONTEXT: ${{ toJson(github) }}
run: | run: |
echo $GITHUB_CONTEXT echo $GITHUB_CONTEXT
# echo "$GITHUB_SHA" # echo "$GITHUB_SHA"
# echo "$GITHUB_REF" # echo "$GITHUB_REF"
# echo "$GITHUB_HEAD_REF" # echo "$GITHUB_HEAD_REF"
@ -124,6 +126,9 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: ~/.stack path: ~/.stack
# XXX if stack.yaml is a symlink, this fails with
# Error: The template is not valid. .github/workflows/push.yml (Line: 103, Col: 14): hashFiles('**.yaml') failed.
# Fail to hash files under directory '/home/runner/work/hledger/hledger'
key: ${{ runner.os }}-stack-global-${{ matrix.plan.ghc }}-${{ hashFiles('**.yaml') }} key: ${{ runner.os }}-stack-global-${{ matrix.plan.ghc }}-${{ hashFiles('**.yaml') }}
restore-keys: | restore-keys: |
${{ runner.os }}-stack-global-${{ matrix.plan.ghc }} ${{ runner.os }}-stack-global-${{ matrix.plan.ghc }}
@ -199,9 +204,7 @@ jobs:
env: env:
stack: ${{ matrix.plan.stack }} stack: ${{ matrix.plan.stack }}
run: | run: |
df -h
$stack setup --install-ghc $stack setup --install-ghc
df -h
if: env.CONTINUE if: env.CONTINUE
- name: Install haskell deps - name: Install haskell deps
@ -209,17 +212,24 @@ jobs:
stack: ${{ matrix.plan.stack }} stack: ${{ matrix.plan.stack }}
run: | run: |
$stack build --test --bench --only-dependencies $stack build --test --bench --only-dependencies
# --no-terminal
if: env.CONTINUE if: env.CONTINUE
- name: Build all hledger modules warning free, optimised and minimised, run unit/doc/bench tests # - name: Build all hledger modules warning free, optimised and minimised, run unit/doc/bench tests
# env:
# stack: ${{ matrix.plan.stack }}
# run: |
# $stack install --test --bench --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --ghc-options=-split-sections --no-terminal
# # build quicker when tweaking ci: $stack install --ghc-options=-Werror --ghc-options=-split-sections --no-terminal
# # -split-sections shrinks binaries by 30% on average here
# # --pedantic --no-run-benchmarks
# if: env.CONTINUE
- name: Build all hledger modules fast, warning free, run unit/doc/bench tests
env: env:
stack: ${{ matrix.plan.stack }} stack: ${{ matrix.plan.stack }}
run: | run: |
$stack install --test --bench --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --ghc-options=-split-sections --no-terminal $stack install --fast --force-dirty --ghc-options=-fforce-recomp --ghc-options=-Werror --test --bench
# build quicker when tweaking ci: $stack install --ghc-options=-Werror --ghc-options=-split-sections --no-terminal # --ghc-options=-split-sections --no-terminal
# -split-sections shrinks binaries by 30% on average here
# --pedantic --no-run-benchmarks
if: env.CONTINUE if: env.CONTINUE
- name: Install shelltestrunner - name: Install shelltestrunner
@ -249,32 +259,28 @@ jobs:
# --no-print-missing-docs is 600% quieter # --no-print-missing-docs is 600% quieter
if: env.CONTINUE if: env.CONTINUE
# artifacts: # - name: Gather executables
# XXX unreliable, and we don't need this for every PR; disable for now # id: exes
# run: |
# mkdir tmp
# cd tmp
# mkdir hledger
# cd hledger
# cp ~/.local/bin/hledger .
# cp ~/.local/bin/hledger-ui .
# cp ~/.local/bin/hledger-web .
# # how to set a context variable, and an attempt to make a nice artifact version suffix:
# # echo "::set-output name=version::$(git branch --show-current | sed 's/-.*//')-$(git rev-parse --short HEAD)"
# if: env.CONTINUE
- name: Gather executables # # XXX intermittent upload failures
id: exes # - name: Upload executables artifact
run: | # uses: actions/upload-artifact@v2
mkdir tmp # with:
cd tmp # # name: hledger-ubuntu-${{ steps.exes.outputs.version }}
mkdir hledger # name: hledger-ubuntu
cd hledger # path: tmp/hledger
cp ~/.local/bin/hledger . # if: env.CONTINUE
cp ~/.local/bin/hledger-ui .
cp ~/.local/bin/hledger-web .
# example of setting a context variable, and an attempt to make a nice artifact version suffix.
# But a constant name is easier in some ways.
# echo "::set-output name=version::$(git branch --show-current | sed 's/-.*//')-$(git rev-parse --short HEAD)"
if: env.CONTINUE
# XXX intermittent upload failures
- name: Upload executables artifact
uses: actions/upload-artifact@v2
with:
# name: hledger-ubuntu-${{ steps.exes.outputs.version }}
name: hledger-ubuntu
path: tmp/hledger
if: env.CONTINUE

View File

@ -1,241 +0,0 @@
# Runs after notable pushes to the branches listed below.
# master is configured to require one or more status checks corresponding to
# enabled matrix plans below (shown in github UI as "build (810, ...").
# So the push process is:
# 1. push new commits to a personal test branch listed below (simon)
# 2. this workflow runs, wait for it to succeed, then
# 3. push the same commits to master, which will now allow it.
#
# Builds unoptimised on x64 linux and runs functional tests,
# using the GHC version(s) enabled below.
name: push CI
on:
push:
branches: [ simon, simon2 ]
# Run this workflow for changes to any file, even trivial doc fixes
# (since merging to master requires a successful run).
# Ideally caching will keep it relatively cheap; avoid over-pushing.
# Run this workflow only for changes to these files (to avoid waste):
# paths:
# - '.github/workflows/push.yml'
# - 'stack*.yaml'
# - 'hledger-lib/**'
# - 'hledger/**'
# - 'hledger-ui/**'
# - 'hledger-web/**'
# - 'bin/*.hs'
# - 'examples/**'
# # and ignore these files: (XXX it would still be nice to check the commit messages)
# # examples
# - '!**.journal'
# - '!**.j'
# - '!**.ledger'
# - '!**.csv'
# # docs
# - '!**.m4'
# - '!**.md'
# - '!**.1'
# - '!**.5'
# - '!**.info'
# - '!**.txt'
# also allow this workflow to be triggered manually
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
plan: # at least the check(s) required by master should be enabled
- { ghc: "86" , stack: "stack --stack-yaml=stack8.6.yaml" }
# - { ghc: "88" , stack: "stack --stack-yaml=stack8.8.yaml" }
# - { ghc: "810", stack: "stack --stack-yaml=stack8.10.yaml" }
# - { ghc: "90" , stack: "stack --stack-yaml=stack.yaml" }
# - { ghc: "92" , stack: "stack --stack-yaml=stack9.2.yaml" }
steps:
- name: Check out
uses: actions/checkout@v2
# have to fetch everything for git describe for --version
with:
fetch-depth: 0
# - name: Print debug output
# env:
# GITHUB_CONTEXT: ${{ toJson(github) }}
# run: |
# echo
# echo "$GITHUB_SHA"
# echo "$GITHUB_REF"
# echo "$GITHUB_HEAD_REF"
# echo "$GITHUB_BASE_REF"
# git log "$GITHUB_BASE_REF"..
# tools/commitlint "$GITHUB_BASE_REF"..
# keep synced in all workflows which do this
- name: Check commit messages
# For a PR, the range will be: master..origin/$GITHUB_HEAD_REF
# For a push it will be: $BEFORE..
# For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range".
# In this and any case where the range is invalid, we'll just skip the check, to avoid false positives
# related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push
env:
BEFORE: ${{ github.event.before }}
# NUM: 5
shell: bash
run: |
RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:-}
echo "debug: last 10 commits:"
echo "$(git log --format='%h -%d %s (%an, %ci)' -10)"
echo "debug: origin/master:"
echo "$(git log --format='%h -%d %s (%an, %ci)' -1 origin/master)"
echo "debug: BEFORE=$BEFORE"
echo "$(git log --format='%h -%d %s (%an, %ci)' -1 $BEFORE)"
echo "debug: GITHUB_HEAD_REF=$GITHUB_HEAD_REF"
echo "$(git log --format='%h -%d %s (%an, %ci)' -1 $GITHUB_HEAD_REF)"
echo "debug: RANGE=$RANGE"
echo "debug: commits to check:"
echo "$(git log --format='%h -%d %s (%an, %ci)' --abbrev-commit --date=relative --date-order $RANGE)"
if git rev-list --quiet $RANGE
then tools/commitlint $RANGE
else echo "could not identify commits, not checking them"
fi
- name: Skip remaining steps if last commit message begins with ;
shell: bash
run: |
echo "git log -1 --pretty='%s' ${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} >> $$.gitlog"
(git log -1 --pretty='%s' ${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} >> $$.gitlog \
&& (grep -qE '^ *;' $$.gitlog || echo "CONTINUE=true" >> $GITHUB_ENV)) \
|| ( echo "could not identify commit range, continuing CI steps"; echo "CONTINUE=true" >> $GITHUB_ENV )
# things to be cached/restored:
- name: Cache stack global package db
id: stack-global
uses: actions/cache@v2
with:
path: ~/.stack
# XXX if stack.yaml is a symlink, this fails with
# Error: The template is not valid. .github/workflows/push.yml (Line: 103, Col: 14): hashFiles('**.yaml') failed.
# Fail to hash files under directory '/home/runner/work/hledger/hledger'
key: ${{ runner.os }}-stack-global-${{ matrix.plan.ghc }}-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-global-${{ matrix.plan.ghc }}
if: env.CONTINUE
- name: Cache stack-installed programs in ~/.local/bin
id: stack-programs
uses: actions/cache@v2
with:
path: ~/.local/bin
key: ${{ runner.os }}-stack-programs-${{ matrix.plan.ghc }}-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-programs-${{ matrix.plan.ghc }}
if: env.CONTINUE
- name: Cache .stack-work
uses: actions/cache@v2
with:
path: .stack-work
key: ${{ runner.os }}-stack-work-${{ matrix.plan.ghc }}-${{ hashFiles('**.yaml') }}
restore-keys: |
${{ runner.os }}-stack-work-${{ matrix.plan.ghc }}
if: env.CONTINUE
- name: Cache hledger-lib/.stack-work
uses: actions/cache@v2
with:
path: hledger-lib/.stack-work
key: ${{ runner.os }}-hledger-lib-stack-work-${{ matrix.plan.ghc }}-${{ hashFiles('hledger-lib/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-lib-stack-work-${{ matrix.plan.ghc }}
if: env.CONTINUE
- name: Cache hledger/.stack-work
uses: actions/cache@v2
with:
path: hledger/.stack-work
key: ${{ runner.os }}-hledger-stack-work-${{ matrix.plan.ghc }}-${{ hashFiles('hledger/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-stack-work-${{ matrix.plan.ghc }}
if: env.CONTINUE
- name: Cache hledger-ui/.stack-work
uses: actions/cache@v2
with:
path: hledger-ui/.stack-work
key: ${{ runner.os }}-hledger-ui-stack-work-${{ matrix.plan.ghc }}-${{ hashFiles('hledger-ui/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-ui-stack-work-${{ matrix.plan.ghc }}
if: env.CONTINUE
- name: Cache hledger-web/.stack-work
uses: actions/cache@v2
with:
path: hledger-web/.stack-work
key: ${{ runner.os }}-hledger-web-stack-work-${{ matrix.plan.ghc }}-${{ hashFiles('hledger-web/package.yaml') }}
restore-keys: |
${{ runner.os }}-hledger-web-stack-work-${{ matrix.plan.ghc }}
if: env.CONTINUE
# actions:
- name: Install stack
run: |
mkdir -p ~/.local/bin
export PATH=~/.local/bin:$PATH
# curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack
if [[ ! -x ~/.local/bin/stack ]]; then curl -sL https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
stack --version
if: env.CONTINUE
- name: Install GHC
env:
stack: ${{ matrix.plan.stack }}
run: |
$stack setup --install-ghc
if: env.CONTINUE
- name: Install haskell deps
env:
stack: ${{ matrix.plan.stack }}
run: |
$stack build --only-dependencies
if: env.CONTINUE
- name: Build hledger fast
env:
stack: ${{ matrix.plan.stack }}
run: |
$stack build --fast --ghc-options=-Werror --force-dirty
# --ghc-options=-fforce-recomp # needed occasionally to clear out stale compiled modules
# --pedantic
if: env.CONTINUE
- name: Install shelltestrunner
env:
stack: ${{ matrix.plan.stack }}
run: |
export PATH=~/.local/bin:$PATH
if [[ ! -x ~/.local/bin/shelltest ]]; then $stack install shelltestrunner-1.9; fi
shelltest --version
if: env.CONTINUE
- name: Test functional tests (excluding addons)
env:
stack: ${{ matrix.plan.stack }}
run: |
export PATH=~/.local/bin:$PATH
COLUMNS=80 $stack exec -- shelltest --execdir -j16 hledger/test -x /_ -x /addons # bin
# XXX func tests in bin are run only with GHC 8.2 for now
if: env.CONTINUE