Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

feat: save meta variables in 'measure' #149

feat: save meta variables in 'measure'

feat: save meta variables in 'measure' #149

Workflow file for this run

name: Haskell Workflow
on:
# Runs on Pull Request updates
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review
# Runs on pushes targeting the default branch
push:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up HLint
uses: haskell-actions/hlint-setup@v2
with:
version: 3.6.1
- name: Run HLint
uses: haskell-actions/hlint-run@v2
with:
path: .
fail-on: warning
build:
name: Build
runs-on: ubuntu-latest
if: "! github.event.pull_request.draft"
outputs:
cache-setup: ${{ steps.cache-keys.outputs.cache-setup }}
cache-packages: ${{ steps.cache-keys.outputs.cache-packages }}
cache-index: ${{ steps.cache-keys.outputs.cache-index }}
cache-work: ${{ steps.cache-keys.outputs.cache-work }}
steps:
- uses: actions/checkout@v4
- name: Install Haskell
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-setup-ghc: true
stack-version: latest
ghc-version: 9.6.3
- name: Generate Cache Keys
id: cache-keys
shell: sh
env:
CACHE_SETUP: ${{ runner.os }}-stack-setup-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
CACHE_PACKAGES: ${{ runner.os }}-stack-packages-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
CACHE_INDEX: ${{ runner.os }}-stack-index-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
CACHE_WORK: ${{ runner.os }}-stack-work-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
run: |
echo "cache-setup=${CACHE_SETUP}" >> $GITHUB_OUTPUT
echo "cache-packages=${CACHE_PACKAGES}" >> $GITHUB_OUTPUT
echo "cache-index=${CACHE_INDEX}" >> $GITHUB_OUTPUT
echo "cache-work=${CACHE_WORK}" >> $GITHUB_OUTPUT
- name: Cache Stack Setup
uses: actions/cache@v3
with:
key: ${{ steps.cache-keys.outputs.cache-setup }}
restore-keys: |
${{ runner.os }}-stack-setup-${{ hashFiles('stack.yaml') }}-
${{ runner.os }}-stack-setup-
${{ runner.os }}-stack-packages-
${{ runner.os }}-stack-
${{ runner.os }}-
path: |
~/.stack/*
!~/.stack/pantry
~/.cabal
*.cabal
cabal.*
- name: Cache Stack Packages Database
uses: actions/cache@v3
with:
key: ${{ steps.cache-keys.outputs.cache-packages }}
restore-keys: |
${{ runner.os }}-stack-packages-${{ hashFiles('stack.yaml') }}-
${{ runner.os }}-stack-packages-
${{ runner.os }}-stack-setup-
${{ runner.os }}-stack-
${{ runner.os }}-
path: |
~/.stack/pantry/*
!~/.stack/pantry/hackage
- name: Cache Stack Packages Index
uses: actions/cache@v3
with:
key: ${{ steps.cache-keys.outputs.cache-packages }}
restore-keys: |
${{ runner.os }}-stack-packages-${{ hashFiles('stack.yaml') }}-
${{ runner.os }}-stack-packages-
${{ runner.os }}-stack-setup-
${{ runner.os }}-stack-
${{ runner.os }}-
path: |
~/.stack/pantry/hackage
- name: Cache Stack Work Directory
uses: actions/cache@v3
with:
key: ${{ steps.cache-keys.outputs.cache-work }}
restore-keys: |
${{ runner.os }}-stack-work-${{ hashFiles('package.yaml') }}-
${{ runner.os }}-stack-work-
${{ runner.os }}-stack-setup-
${{ runner.os }}-stack-
${{ runner.os }}-
path: |
dist-newstyle
.stack-work
*.cabal
cabal.*
- name: Generate Cabal File
shell: sh
run: |
stack build --dry-run
- name: Update Package List
shell: sh
run: |
stack update
- name: Install Dependencies
shell: sh
run: |
stack build --only-dependencies --no-run-benchmarks --no-run-tests
- name: Build Haskell Sources
shell: sh
run: |
stack build --no-run-benchmarks --no-run-tests
test:
name: Tests
needs: build
runs-on: ubuntu-latest
if: "! github.event.pull_request.draft"
steps:
- uses: actions/checkout@v4
- name: Install Haskell
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-setup-ghc: true
stack-version: latest
ghc-version: 9.6.3
- name: Restore Cache Stack Setup
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-setup }}
fail-on-cache-miss: true
path: |
~/.stack/*
!~/.stack/pantry
~/.cabal
*.cabal
cabal.*
- name: Restore Cache Stack Packages Database
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-packages }}
fail-on-cache-miss: true
path: |
~/.stack/pantry/*
!~/.stack/pantry/hackage
- name: Restore Cache Stack Packages Index
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-packages }}
fail-on-cache-miss: true
path: |
~/.stack/pantry/hackage
- name: Restore Cache Stack Work Directory
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-work }}
fail-on-cache-miss: true
path: |
dist-newstyle
.stack-work
*.cabal
cabal.*
- name: Run Tests
shell: sh
run: |
stack test --no-run-benchmarks
bench:
name: Benchmarks
needs: build
runs-on: ubuntu-latest
if: "! github.event.pull_request.draft"
env:
BENCHMARKS_ARTIFACT: benchmarks
BENCHMARKS_ARCHIVE: benchmarks.tar
BENCHMARKS_PATH: bench/output
outputs:
artifact: ${{ env.BENCHMARKS_ARTIFACT }}
archive: ${{ env.BENCHMARKS_ARCHIVE }}
steps:
- uses: actions/checkout@v4
- name: Install Haskell
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-setup-ghc: true
stack-version: latest
ghc-version: 9.6.3
- name: Restore Cache Stack Setup
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-setup }}
fail-on-cache-miss: true
path: |
~/.stack/*
!~/.stack/pantry
~/.cabal
*.cabal
cabal.*
- name: Restore Cache Stack Packages Database
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-packages }}
fail-on-cache-miss: true
path: |
~/.stack/pantry/*
!~/.stack/pantry/hackage
- name: Restore Cache Stack Packages Index
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-packages }}
fail-on-cache-miss: true
path: |
~/.stack/pantry/hackage
- name: Restore Cache Stack Work Directory
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-work }}
fail-on-cache-miss: true
path: |
dist-newstyle
.stack-work
*.cabal
cabal.*
- name: Run benchmarks
shell: sh
run: |
stack bench --no-run-tests
- name: Cache Benchmark Results
uses: actions/cache@v3
with:
key: ${{ runner.os }}-stack-bench-${{ hashFiles('bench/output/*') }}
restore-keys: |
${{ runner.os }}-stack-bench-
${{ runner.os }}-stack-
${{ runner.os }}-
path: |
${{ env.BENCHMARKS_PATH }}
- name: Pack Benchmarks Results
shell: sh
run: |
tar -cvf "${BENCHMARKS_ARCHIVE}" -C "${BENCHMARKS_PATH}" .
- name: Upload Benchmark Results
uses: actions/upload-artifact@v3
with:
name: ${{ env.BENCHMARKS_ARTIFACT }}
path: ${{ env.BENCHMARKS_ARCHIVE }}
if-no-files-found: error
docs:
name: Build Docs
needs: build
runs-on: ubuntu-latest
if: "! github.event.pull_request.draft"
env:
# if internal items should be exposed in the documentation
INTERNAL_DOCUMENTATION: true
outputs:
cache-dist: ${{ steps.cache-keys.outputs.cache-dist }}
html-dir: ${{ steps.index.outputs.html-dir }}
steps:
- uses: actions/checkout@v4
- name: Install Haskell
uses: haskell-actions/setup@v2
with:
enable-stack: true
stack-setup-ghc: true
stack-version: latest
ghc-version: 9.6.3
cabal-version: latest
- name: Restore Cache Stack Setup
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-setup }}
fail-on-cache-miss: true
path: |
~/.stack/*
!~/.stack/pantry
~/.cabal
*.cabal
cabal.*
- name: Restore Cache Stack Work Directory
uses: actions/cache/restore@v3
with:
key: ${{ needs.build.outputs.cache-work }}
fail-on-cache-miss: true
path: |
dist-newstyle
.stack-work
*.cabal
cabal.*
- name: Generate Cache Keys
id: cache-keys
shell: sh
env:
CACHE_DIST: ${{ runner.os }}-cabal-dist-${{ hashFiles('*.cabal') }}-${{ hashFiles('**/*.hs') }}
run: |
echo "cache-dist=${CACHE_DIST}" >> $GITHUB_OUTPUT
- name: Cache Cabal Dist
uses: actions/cache@v3
with:
key: ${{ steps.cache-keys.outputs.cache-dist }}
restore-keys: |
${{ runner.os }}-cabal-dist-${{ hashFiles('*.cabal') }}-
${{ runner.os }}-cabal-dist-
${{ runner.os }}-cabal-
${{ runner.os }}-stack-work-
${{ runner.os }}-stack-
${{ runner.os }}-
path: |
dist-newstyle
*.cabal
cabal.*
- name: Configure Cabal
shell: sh
env:
HADDOCK_INTERNAL: ${{ env.INTERNAL_DOCUMENTATION && '--haddock-internal' || '' }}
run: |
SNAPSHOT_DB=$(stack path --snapshot-pkg-db)
LOCAL_DB=$(stack path --local-pkg-db)
cabal configure --disable-backup --package-db=clear \
--package-db=global --package-db="${SNAPSHOT_DB}" --package-db="${LOCAL_DB}" \
--enable-documentation --disable-tests --disable-benchmarks \
${HADDOCK_INTERNAL} --haddock-hyperlink-source --haddock-quickjump \
--haddock-html-location='https://hackage.haskell.org/package/$pkg-$version/docs'
- name: Build Documentation
shell: sh
run: |
cabal haddock
- name: Find Documentation Index
id: index
shell: bash
run: |
INDEX_HTML=$(ls -l -1 --full-time dist-newstyle/build/*/ghc-*/*-*/doc/html/*/index.html |\
awk '{print$6,$7,$9}' | sort -r | head -n 1 | awk '{print$3}')
OUTPUT_DIR=$(dirname "$INDEX_HTML")
echo "Documentation should be at $OUTPUT_DIR"
echo "html-dir=${OUTPUT_DIR}" >> $GITHUB_OUTPUT
deploy:
name: Deploy Docs
needs: [docs, bench]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and
# latest queued. However, do NOT cancel in-progress runs as we want to allow these production
# deployments to complete.
concurrency:
group: pages
cancel-in-progress: false
env:
# Directory where the static assets will be found
PAGES_DIR: site
# Directory for the benchmark results
BENCHMARKS: site/benchmarks
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Restore Cache Cabal Dist
uses: actions/cache/restore@v3
with:
key: ${{ needs.docs.outputs.cache-dist }}
fail-on-cache-miss: true
path: |
dist-newstyle
*.cabal
cabal.*
- name: Copy Documentation to Page
shell: sh
env:
BUILD_DIR: ${{ needs.docs.outputs.html-dir }}
run: |
cp -r "${BUILD_DIR}" "${PAGES_DIR}"
- name: Download Benchmark Results
uses: actions/download-artifact@v3
with:
name: ${{ needs.bench.outputs.artifact }}
path: .
- name: Copy Benchmarks to page
shell: sh
env:
ARCHIVE: ${{ needs.bench.outputs.archive }}
run: |
mkdir -p "${BENCHMARKS}"
tar -xvf "${ARCHIVE}" -C "${BENCHMARKS}"
- name: Temporary Tools Directory
id: temp
shell: sh
run: |
TOOLS=$(pwd)/tools
mkdir -p "${TOOLS}"
echo "tools=${TOOLS}" >> $GITHUB_OUTPUT
- name: Construct Benchmarks Index
uses: Exponential-Workload/create-index-action@master
with:
path: ${{ steps.temp.outputs.tools }}/create-index
dir: ${{ env.BENCHMARKS }}
- name: Setup GitHub Pages
uses: actions/configure-pages@v3
- uses: actions/upload-pages-artifact@v2
with:
path: ${{ env.PAGES_DIR }}
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2