261 lines
		
	
	
		
			8.7 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			261 lines
		
	
	
		
			8.7 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
| # Thorough linux CI tests: build, test, benchmark, haddock &
 | |
| # run functional tests, with all supported GHC versions.
 | |
| #
 | |
| # Runs: periodically, on notable pull request to master, and on
 | |
| # notable push to master or ci-linux.
 | |
| 
 | |
| name: linux full CI
 | |
| 
 | |
| on:
 | |
|   schedule:
 | |
|   - cron: "0 07 * * 0"  # sunday midnight pacific
 | |
|   pull_request:
 | |
|     branches: [ master ]
 | |
|     paths:
 | |
|       - '.github/workflows/linux.yml'
 | |
|       - 'stack*.yaml'
 | |
|       - 'hledger-lib/**'
 | |
|       - 'hledger/**'
 | |
|       - 'hledger-ui/**'
 | |
|       - 'hledger-web/**'
 | |
|       - 'tests/**'
 | |
|       - '!**.md'
 | |
|       - '!**.1'
 | |
|       - '!**.5'
 | |
|       - '!**.info'
 | |
|       - '!**.txt'
 | |
|   push:
 | |
|     branches: [ master, ci-linux ]
 | |
|     paths:
 | |
|       - '.github/workflows/linux.yml'
 | |
|       - 'stack*'
 | |
|       - 'hledger-lib/**'
 | |
|       - 'hledger/**'
 | |
|       - 'hledger-ui/**'
 | |
|       - 'hledger-web/**'
 | |
|       - 'tests/**'
 | |
|       - '!**.md'
 | |
|       - '!**.1'
 | |
|       - '!**.5'
 | |
|       - '!**.info'
 | |
|       - '!**.txt'
 | |
| 
 | |
| jobs:
 | |
|   build:
 | |
|     strategy:
 | |
|       fail-fast: false
 | |
|       matrix:
 | |
|         plan:
 | |
|         - { key: "80", args: "--stack-yaml=stack8.0.yaml" }
 | |
|         - { key: "82", args: "--stack-yaml=stack8.2.yaml" }
 | |
|         - { key: "84", args: "--stack-yaml=stack8.4.yaml" }
 | |
|         - { key: "86", args: "--stack-yaml=stack8.6.yaml" }
 | |
|         - { key: "88", args: "--stack-yaml=stack.yaml" }
 | |
|         - { key: "810", args: "--stack-yaml=stack8.10.yaml" }
 | |
|     runs-on: ubuntu-latest
 | |
| 
 | |
|     steps:
 | |
| 
 | |
|     - name: Check out
 | |
|       uses: actions/checkout@v2
 | |
|       # deep clone so we can restore timestamps (see below)
 | |
|       with:
 | |
|         fetch-depth: 0
 | |
| 
 | |
|     # Restore timestamps to help stack not rebuild unchanged files.
 | |
|     # https://stackoverflow.com/questions/60906336
 | |
|     # https://stackoverflow.com/a/36243002/84401
 | |
|     # https://www.reddit.com/r/haskell/comments/g00ldn/haskell_stack_on_github_actions/
 | |
|     - name: Restore source file timestamps
 | |
|       run: |
 | |
|         git ls-tree -r --name-only HEAD | while read filename; do
 | |
|           TS="$(git log -1 --format="%ct" -- ${filename})"
 | |
|           touch "${filename}" -mt "$(date --date="@$TS" "+%Y%m%d%H%M.%S")"
 | |
|         done        
 | |
| 
 | |
|     # things to be cached/restored:
 | |
| 
 | |
|     - name: Cache stack global package db
 | |
|       id:   stack-global
 | |
|       uses: actions/cache@v2
 | |
|       with:
 | |
|         path: ~/.stack
 | |
|         key: ${{ runner.os }}-stack-global-${{ matrix.plan.key }}-${{ hashFiles('**.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-stack-global-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-stack-global          
 | |
| 
 | |
|     - 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.key }}-${{ hashFiles('**.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-stack-programs-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-stack-programs          
 | |
| 
 | |
|     - name: Cache .stack-work
 | |
|       uses: actions/cache@v2
 | |
|       with:
 | |
|         path: .stack-work
 | |
|         key: ${{ runner.os }}-stack-work-${{ matrix.plan.key }}-${{ hashFiles('**.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-stack-work-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-stack-work          
 | |
| 
 | |
|     - 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.key }}-${{ hashFiles('hledger-lib/package.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-hledger-lib-stack-work-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-hledger-lib-stack-work          
 | |
| 
 | |
|     - name: Cache hledger/.stack-work
 | |
|       uses: actions/cache@v2
 | |
|       with:
 | |
|         path: hledger/.stack-work
 | |
|         key: ${{ runner.os }}-hledger-stack-work-${{ matrix.plan.key }}-${{ hashFiles('hledger/package.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-hledger-stack-work-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-hledger-stack-work          
 | |
| 
 | |
|     - 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.key }}-${{ hashFiles('hledger-ui/package.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-hledger-ui-stack-work-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-hledger-ui-stack-work          
 | |
| 
 | |
|     - 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.key }}-${{ hashFiles('hledger-web/package.yaml') }}
 | |
|         restore-keys: |
 | |
|           ${{ runner.os }}-hledger-web-stack-work-${{ matrix.plan.key }}
 | |
|           ${{ runner.os }}-hledger-web-stack-work          
 | |
| 
 | |
|     # For now due to
 | |
|     # https://github.com/actions/virtual-environments/issues/709
 | |
|     # there's only 4.8G free at this point, and we must free up space.
 | |
|     - name: Free disk space
 | |
|       run: |
 | |
|         df -h /
 | |
|         # 8G:
 | |
|         sudo swapoff -a
 | |
|         sudo rm -f /swapfile
 | |
|         # 3G:
 | |
|         sudo apt clean
 | |
|         # 3G, takes 30s:
 | |
|         # docker image ls -aq
 | |
|         # docker rmi $(docker image ls -aq)
 | |
|         # 1G:
 | |
|         find ~/work/_temp -name "cache.tgz" -exec rm -f {} \;
 | |
|         # 4G, takes 14s:
 | |
|         # sudo rm -rf "/usr/local/share/boost"
 | |
|         # 2G:
 | |
|         sudo rm -rf "$AGENT_TOOLSDIRECTORY"
 | |
|         df -h /        
 | |
| 
 | |
|     # actions:
 | |
| 
 | |
|     - name: Install stack
 | |
|       # curl -L https://get.haskellstack.org/stable/linux-x86_64.tar.gz | tar xz --wildcards --strip-components=1 -C $INSTALLDIR '*/stack'
 | |
|       # mkdir -p ~/.local/bin
 | |
|       # export PATH=~/.local/bin:$PATH
 | |
|       # if [[ ! -x ~/.local/bin/stack ]]; then curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack'; chmod a+x ~/.local/bin/stack; fi
 | |
|       run: |
 | |
|         stack --version        
 | |
| 
 | |
|     - name: Install GHC
 | |
|       run: |
 | |
|         df -h
 | |
|         stack $ARGS setup --install-ghc
 | |
|         df -h        
 | |
| 
 | |
|       env:
 | |
|         ARGS: ${{ matrix.plan.args }}
 | |
| 
 | |
|     - name: Install haskell deps
 | |
|       run: |
 | |
|         stack $ARGS build --test --bench --only-dependencies
 | |
|         #  --no-terminal        
 | |
|       env:
 | |
|         ARGS: ${{ matrix.plan.args }}
 | |
| 
 | |
|     - name: Build hledger quickly warning free, run unit tests, run doc tests
 | |
|       run: |
 | |
|         stack $ARGS build --test --bench --fast --ghc-options=-Werror --no-terminal
 | |
|         # --pedantic --no-run-benchmarks        
 | |
|       env:
 | |
|         ARGS: ${{ matrix.plan.args }}
 | |
| 
 | |
|     - name: Install shelltestrunner
 | |
|       run: |
 | |
|         export PATH=~/.local/bin:$PATH
 | |
|         if [[ ! -x ~/.local/bin/shelltest ]]; then stack $ARGS install shelltestrunner-1.9; fi
 | |
|         shelltest --version        
 | |
|       env:
 | |
|         ARGS: ${{ matrix.plan.args }}
 | |
| 
 | |
|     - name: Test functional tests (excluding addons)
 | |
|       run: |
 | |
|         export PATH=~/.local/bin:$PATH
 | |
|         COLUMNS=80 stack $ARGS exec -- shelltest --execdir -j16 tests -x /bin -x /addons        
 | |
|       env:
 | |
|         ARGS: ${{ matrix.plan.args }}
 | |
| 
 | |
|     - name: Test haddock generation
 | |
|       shell: bash
 | |
|       run: |
 | |
|         time stack $ARGS build --fast --haddock --no-haddock-deps --no-haddock-hyperlink-source --haddock-arguments="--no-print-missing-docs"        
 | |
|       # --no-haddock-hyperlink-source is 25% faster
 | |
|       # --no-print-missing-docs is 600% quieter
 | |
|       env:
 | |
|         ARGS: ${{ matrix.plan.args }}
 | |
| 
 | |
|     # - name: show stuff
 | |
|     #   run: |
 | |
|     #     if [[ -e ~/.stack ]]; then ls -lFRa ~/.stack; fi
 | |
| 
 | |
|     # - name: show stuff
 | |
|     #   run: |
 | |
|     #     if [[ -e ~/.local/bin ]]; then ls -lFRa ~/.local/bin; fi
 | |
| 
 | |
| 
 | |
| 
 | |
| # docs:
 | |
| 
 | |
| # based on https://gist.github.com/mstksg/11f753d891cee5980326a8ea8c865233
 | |
| # http://www.btellez.com/posts/triggering-github-actions-with-webhooks.html
 | |
| # https://help.github.com/en/actions
 | |
| # https://help.github.com/en/actions/reference/events-that-trigger-workflows
 | |
| # https://help.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule
 | |
| # https://help.github.com/en/actions/configuring-and-managing-workflows/caching-and-storing-workflow-data
 | |
| # https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows
 | |
| # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#supported-runners-and-hardware-resources
 | |
| # https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
 | |
| # https://github.community/t5/GitHub-Actions/bd-p/actions
 | |
| 
 | |
| # https://github.com/actions/cache
 | |
| # https://github.com/marketplace/actions/cache
 | |
| 
 | |
| # https://github.com/actions/upload-artifact
 | |
| # https://github.com/c-hive/gha-remove-artifacts
 | |
| 
 | |
| # https://github.com/actions/setup-haskell
 | |
| 
 | |
| # https://github.com/marketplace/actions/checkout
 | |
| # https://github.com/sdras/awesome-actions
 | |
| 
 | |
| # https://sevenzip.osdn.jp/chm/cmdline/commands/index.htm
 | |
| 
 | |
| # https://github.com/mxschmitt/action-tmate
 | |
| #     - name: Setup tmate session
 | |
| #      uses: mxschmitt/action-tmate@v1
 |