Skip to content

Commit

Permalink
Enable the caller to select the newest, oldest-supported GHC, or both
Browse files Browse the repository at this point in the history
  • Loading branch information
Kleidukos committed Sep 3, 2024
1 parent 588092b commit 83583dc
Show file tree
Hide file tree
Showing 15 changed files with 543 additions and 188 deletions.
135 changes: 100 additions & 35 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Tests Pipeline
on:
pull_request:
push:
branches: ['main']
branches: ["main"]

jobs:
generate-matrix:
name: 'Generate matrix from cabal'
outputs:
name: "Generate matrix from cabal"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
Expand All @@ -17,76 +17,97 @@ jobs:
uses: kleidukos/get-tested@0.1.7.1
with:
cabal-file: get-tested.cabal
ubuntu-version: 'latest'
macos-version: 'latest'
ubuntu-version: latest
version: 0.1.7.0
tests:
build:
name: ${{ matrix.ghc }} on ${{ matrix.os }}
needs: generate-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Checkout base repo
uses: actions/checkout@v4

- name: "Install tools"
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
.github/workflows/install-tools.sh
sudo apt install upx-ucl
- name: Checkout base repo
uses: actions/checkout@v4

- name: Set up Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: 'latest'
cabal-version: "latest"

- name: Configure
run: |
ARCHITECTURE=$(uname -m)
echo "ARCH=$ARCHITECTURE" >> $GITHUB_ENV
echo "REPORT_NAME=report-${{ matrix.os }}-ghc-${{ matrix.ghc }}.xml" >> $GITHUB_ENV
echo ${{ env.ARCH }}
cabal configure --enable-tests
- name: Freeze
run: cabal freeze --project-file=cabal.release.project

- name: Cache
uses: actions/cache@v4.0.2
uses: actions/cache@v4
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-${{ hashFiles('**/plan.json') }}
path: ${{ steps.setup-haskell.outputs.cabal-store }}
restore-keys: ${{ runner.os }}-ghc-${{ matrix.ghc }}-

- name: Build
run: cabal build --project-file=cabal.release.project

- name: Test
run: cabal test --project-file=cabal.release.project all
run: |
cabal test --project-file=cabal.release.project --test-options "--xml=../get-tested/${{ env.REPORT_NAME }}" all
- name: Upload the test report
uses: actions/upload-artifact@v4
if: success() || failure() # always run even if the previous step fails
with:
name: ${{ env.REPORT_NAME }}
path: ${{ env.REPORT_NAME }}

- name: Install
run: |
bin=$(cabal -v0 --project-file=cabal.static.project list-bin get-tested)
bin=$(cabal -v0 --project-file=cabal.release.project list-bin get-tested)
mkdir distribution
cp ${bin} distribution/get-tested
- name: File type
run: file distribution/get-tested
- name: Post-process executables
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
for executable in distribution/*; do
strip "${executable}"
upx -9 "${executable}"
done
- name: Package the get-tested executable
run: |
GETTESTED_EXEC=distribution/get-tested
.github/workflows/process-binaries.sh
archive="get-tested-head-${{ matrix.os }}-${{ env.ARCH }}-ghc-${{ matrix.ghc }}.tar.gz"
DIR=$(dirname $GETTESTED_EXEC)
FILE=$(basename $GETTESTED_EXEC)
GETTESTED_EXEC_TAR=get-tested-head-${{ runner.os }}-${{ env.ARCH }}.tar.gz
GETTESTED_EXEC_TAR=${archive}
tar -czvf $GETTESTED_EXEC_TAR -C $DIR $FILE
echo GETTESTED_EXEC_TAR=$GETTESTED_EXEC_TAR >> $GITHUB_ENV
echo "ARTIFACT_NAME=artifact-${{ matrix.os }}-ghc-${{ matrix.ghc }}" >> $GITHUB_ENV
- name: Upload the get-tested executable
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifact
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.GETTESTED_EXEC_TAR }}

build-alpine:
name: 9.10.1 on alpine-3.19
name: 9.10.1 on alpine-3.20
runs-on: ubuntu-latest
container: 'alpine:3.19'
container: "alpine:3.20"
needs: generate-matrix
steps:
- name: Install extra dependencies
Expand All @@ -103,13 +124,14 @@ jobs:
- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: '9.10.1'
cabal-version: 'latest'
ghc-version: "9.10.1"
cabal-version: "latest"

- name: Configure
run: |
ARCHITECTURE=$(uname -m)
echo "ARCH=$ARCHITECTURE" >> $GITHUB_ENV
echo "REPORT_NAME=report-alpine-ghc-9.10.1.xml" >> $GITHUB_ENV
echo ${{ env.ARCH }}
cabal configure --enable-tests
Expand All @@ -126,7 +148,15 @@ jobs:
run: cabal build --project-file=cabal.static.project

- name: Test
run: cabal test --project-file=cabal.static.project all
run: |
cabal test --project-file=cabal.static.project --test-options "--xml=../get-tested/${{ env.REPORT_NAME }}" all
- name: Upload the test report
uses: actions/upload-artifact@v4
if: success() || failure() # always run even if the previous step fails
with:
name: ${{ env.REPORT_NAME }}
path: ${{ env.REPORT_NAME }}

- name: Install
run: |
Expand All @@ -137,36 +167,71 @@ jobs:
- name: File type
run: file distribution/get-tested

- name: Post-process executables
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
for executable in distribution/*; do
strip "${executable}"
upx -9 "${executable}"
done
- name: Tar get-tested executable
run: |
GETTESTED_EXEC=distribution/get-tested
.github/workflows/process-binaries.sh
DIR=$(dirname $GETTESTED_EXEC)
FILE=$(basename $GETTESTED_EXEC)
GETTESTED_EXEC_TAR=get-tested-head-${{ runner.os }}-static-${{ env.ARCH }}.tar.gz
tar -czvf $GETTESTED_EXEC_TAR -C $DIR $FILE
echo GETTESTED_EXEC_TAR=$GETTESTED_EXEC_TAR >> $GITHUB_ENV
echo "ARTIFACT_NAME=artifact-alpine-3.20-ghc-${{ matrix.ghc }}" >> $GITHUB_ENV
- name: Upload get-tested executable to workflow artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifact
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.GETTESTED_EXEC_TAR }}

collect-test-results:
name: Collect test results
runs-on: ubuntu-latest
if: ${{ always() }}
needs: ['build', 'build-alpine']
steps:
- name: Install junitparser
run: |
pip install junitparser==3.2.0
- name: Download Test Report
uses: actions/download-artifact@v4
with:
pattern: report-*
merge-multiple: true

- name: Merge XML files
run: |
junitparser merge --glob *.xml final-report.xml
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
with:
commit: ${{github.event.workflow_run.head_sha}}
report_paths: 'final-report.xml'

prerelease-head:
name: Create a GitHub prerelease with the binary artifacts
runs-on: ubuntu-latest
needs: ['tests', 'build-alpine']
needs: ["build", "build-alpine"]

steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
pattern: artifact-*
merge-multiple: true
path: ./out

- name: Release
- name: Pre-release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
draft: true
prerelease: true
files: ./out/*
tag_name: get-tested-head
5 changes: 3 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
with:
pattern: |
app/**/*.hs
src/**/*.hs
test/**/*.hs
hlint:
runs-on: ubuntu-latest
Expand All @@ -29,6 +31,5 @@ jobs:
- name: 'Run HLint'
uses: haskell-actions/hlint-run@v2
with:
path: '["app"]'
path: '["app", "test", "src"]'
fail-on: warning

6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Revision history for get-tested
# CHANGELOG

## 0.1.8.0 -- 2024-09-2

* Provide the `--newest` and `--oldest` flags to pick the newest or oldest-supported GHC, or both.

## 0.1.5.0 -- 2023-09-25

Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ test: ## Run the test suite
@cabal test

lint: ## Run the code linter (HLint)
@find app -name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}
@find app src test -name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}

style: ## Run the code styler (stylish-haskell)
@fourmolu -q --mode inplace app
style: ## Run the code styler (fourmolu)
@fourmolu -q --mode inplace app src test
@cabal-fmt -i *.cabal

help: ## Display this help message
Expand Down
86 changes: 0 additions & 86 deletions app/Extract.hs

This file was deleted.

Loading

0 comments on commit 83583dc

Please sign in to comment.