Skip to content

Commit aaf9d5e

Browse files
committed
Add github CI
1 parent 3541e40 commit aaf9d5e

File tree

3 files changed

+224
-0
lines changed

3 files changed

+224
-0
lines changed

.github/scripts/brew.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
5+
. .github/scripts/env.sh
6+
7+
if [ -e "$HOME/.brew" ] ; then
8+
(
9+
cd "$HOME/.brew"
10+
git fetch --depth 1
11+
git reset --hard origin/master
12+
)
13+
else
14+
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
15+
fi
16+
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
17+
18+
mkdir -p $CI_PROJECT_DIR/.brew_cache
19+
export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache
20+
mkdir -p $CI_PROJECT_DIR/.brew_logs
21+
export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs
22+
mkdir -p /private/tmp/.brew_tmp
23+
export HOMEBREW_TEMP=/private/tmp/.brew_tmp
24+
25+
brew update
26+
brew install ${1+"$@"}
27+
28+
29+
set -eux
30+
31+
. .github/scripts/env.sh
32+
33+
if [ -e "$HOME/.brew" ] ; then
34+
(
35+
cd "$HOME/.brew"
36+
git fetch --depth 1
37+
git reset --hard origin/master
38+
)
39+
else
40+
git clone --depth=1 https://github.com/Homebrew/brew "$HOME/.brew"
41+
fi
42+
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$PATH"
43+
44+
mkdir -p $CI_PROJECT_DIR/.brew_cache
45+
export HOMEBREW_CACHE=$CI_PROJECT_DIR/.brew_cache
46+
mkdir -p $CI_PROJECT_DIR/.brew_logs
47+
export HOMEBREW_LOGS=$CI_PROJECT_DIR/.brew_logs
48+
mkdir -p /private/tmp/.brew_tmp
49+
export HOMEBREW_TEMP=/private/tmp/.brew_tmp
50+
51+
brew update
52+
brew install ${1+"$@"}
53+

.github/scripts/env.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
if [ "${RUNNER_OS}" = "Windows" ] ; then
4+
ext=".exe"
5+
else
6+
ext=''
7+
fi
8+
9+
export DEBIAN_FRONTEND=noninteractive
10+
export TZ=Asia/Singapore
11+
12+
export OS="$RUNNER_OS"
13+
export PATH="$HOME/.local/bin:$PATH"
14+
15+
if [ "${RUNNER_OS}" = "Windows" ] ; then
16+
# on windows use pwd to get unix style path
17+
CI_PROJECT_DIR="$(pwd)"
18+
export CI_PROJECT_DIR
19+
export GHCUP_INSTALL_BASE_PREFIX="/c"
20+
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/ghcup/bin"
21+
export PATH="$GHCUP_BIN:$PATH"
22+
export CABAL_DIR="C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
23+
else
24+
export CI_PROJECT_DIR="${GITHUB_WORKSPACE}"
25+
export GHCUP_INSTALL_BASE_PREFIX="$CI_PROJECT_DIR"
26+
export GHCUP_BIN="$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin"
27+
export PATH="$GHCUP_BIN:$PATH"
28+
export CABAL_DIR="$CI_PROJECT_DIR/cabal"
29+
export CABAL_CACHE="$CI_PROJECT_DIR/cabal-cache"
30+
fi

.github/workflows/test.yaml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Haskell CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest]
17+
ghc: ['8.0', '8.2', '8.4', '8.6', '8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8']
18+
cabal: ['3.8.1.0']
19+
include:
20+
- os: macOS-latest
21+
ghc: '9.4'
22+
cabal: '3.8.1.0'
23+
- os: macOS-latest
24+
ghc: '9.6'
25+
cabal: '3.8.1.0'
26+
- os: windows-latest
27+
ghc: '9.4'
28+
cabal: '3.8.1.0'
29+
- os: windows-latest
30+
ghc: '9.6'
31+
cabal: '3.8.1.0'
32+
steps:
33+
- uses: actions/checkout@v3
34+
35+
- name: Install dependencies (Ubuntu)
36+
if: runner.os == 'Linux'
37+
run: |
38+
sudo apt-get -y update
39+
sudo apt-get -y install libtinfo5 libtinfo6 libncurses5 libncurses6
40+
41+
- name: Install ghc/cabal
42+
run: |
43+
set -eux
44+
ghcup install ghc --set ${{ matrix.ghc }}
45+
ghcup install cabal ${{ matrix.cabal }}
46+
shell: bash
47+
48+
- name: Build
49+
run: |
50+
set -eux
51+
[ "$(ghc --numeric-version)" = "${{ matrix.ghc }}" ]
52+
cabal update
53+
cabal build --enable-tests --enable-benchmarks
54+
cabal test
55+
cabal bench
56+
cabal haddock
57+
cabal check
58+
cabal sdist
59+
shell: bash
60+
61+
i386:
62+
runs-on: ubuntu-latest
63+
container:
64+
image: i386/ubuntu:bionic
65+
steps:
66+
- name: Install
67+
run: |
68+
apt-get update -y
69+
apt-get install -y autoconf build-essential zlib1g-dev libgmp-dev curl libncurses5 libtinfo5 libncurses5-dev libtinfo-dev
70+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 sh
71+
- uses: actions/checkout@v1
72+
- name: Test
73+
run: |
74+
. ~/.ghcup/env
75+
cabal update
76+
cabal test
77+
cabal bench
78+
79+
# We use github.com/haskell self-hosted runners for ARM testing.
80+
# If they become unavailable in future, put ['armv7', 'aarch64']
81+
# back to emulation jobs above.
82+
arm:
83+
runs-on: [self-hosted, Linux, ARM64]
84+
strategy:
85+
fail-fast: true
86+
matrix:
87+
arch: [arm32v7, arm64v8]
88+
steps:
89+
- uses: docker://hasufell/arm64v8-ubuntu-haskell:focal
90+
name: Cleanup
91+
with:
92+
args: "find . -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +"
93+
94+
- name: Checkout code
95+
uses: actions/checkout@v3
96+
97+
- if: matrix.arch == 'arm32v7'
98+
uses: docker://hasufell/arm32v7-ubuntu-haskell:focal
99+
name: Run build (arm32v7 linux)
100+
with:
101+
args: sh -c "cabal update && ghcup install ghc --isolate=/usr --force 9.2.2 && cabal test -w ghc-9.2.2 && cabal bench -w ghc-9.2.2"
102+
103+
- if: matrix.arch == 'arm64v8'
104+
uses: docker://hasufell/arm64v8-ubuntu-haskell:focal
105+
name: Run build (arm64v8 linux)
106+
with:
107+
args: sh -c "cabal update && ghcup install ghc --isolate=/usr --force 9.2.2 && cabal test -w ghc-9.2.2 && cabal bench -w ghc-9.2.2"
108+
109+
darwin_arm:
110+
runs-on: ${{ matrix.os }}
111+
env:
112+
MACOSX_DEPLOYMENT_TARGET: 10.13
113+
strategy:
114+
fail-fast: false
115+
matrix:
116+
include:
117+
- os: [self-hosted, macOS, ARM64]
118+
ghc: 8.10.7
119+
- os: [self-hosted, macOS, ARM64]
120+
ghc: 9.2.8
121+
- os: [self-hosted, macOS, ARM64]
122+
ghc: 9.4.7
123+
steps:
124+
- name: Checkout code
125+
uses: actions/checkout@v3
126+
127+
- name: Run build
128+
run: |
129+
bash .github/scripts/brew.sh git coreutils llvm@11 autoconf automake
130+
export PATH="$HOME/.brew/bin:$HOME/.brew/sbin:$HOME/.brew/opt/llvm@11/bin:$PATH"
131+
export CC="$HOME/.brew/opt/llvm@11/bin/clang"
132+
export CXX="$HOME/.brew/opt/llvm@11/bin/clang++"
133+
export LD=ld
134+
export AR="$HOME/.brew/opt/llvm@11/bin/llvm-ar"
135+
export RANLIB="$HOME/.brew/opt/llvm@11/bin/llvm-ranlib"
136+
. .github/scripts/env.sh
137+
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_INSTALL_NO_STACK=1 BOOTSTRAP_HASKELL_GHC_VERSION=${{ matrix.ghc }} BOOTSTRAP_HASKELL_ADJUST_BASHRC=yes sh
138+
cabal test
139+
cabal bench
140+
env:
141+
HOMEBREW_CHANGE_ARCH_TO_ARM: 1

0 commit comments

Comments
 (0)