-
Notifications
You must be signed in to change notification settings - Fork 6
153 lines (150 loc) · 5.31 KB
/
telomare-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# comment to fire up github actions 2
name: "Telomare CI"
on:
pull_request:
push:
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v25
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v14
with:
name: telomare
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
extraPullNames: nix-community
- name: Build and test
run: |
# echo cachix use
# cachix use iohk
echo nix build and tests:
nix -Lv flake check
echo "Setting up cabal..."
nix -Lv develop -c cabal update
echo "Testing telomare-repl..."
REPL_OUTPUT=$(nix -Lv develop -c cabal run telomare-repl -- --expr 'succ 7' 2>/dev/null | tail -n 1)
echo "REPL output: $REPL_OUTPUT"
if [[ "$REPL_OUTPUT" == "8" ]]; then
echo "REPL test passed"
else
echo "REPL test failed: expected 8, got '$REPL_OUTPUT'"
exit 1
fi
echo building for legacy nix-shell:
nix-build
nix-shell --run "echo OK"
echo ${{ github.ref }}
echo ${{ github.repository }}
format:
runs-on: ubuntu-latest
steps:
- name: Checkout telomare repository
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
with:
name: telomare
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
extraPullNames: nix-community
- name: stylish-haskell formatting
run: |
nix develop -c stylish-haskell -irv .
output=$(git diff)
if [ "$output" = "" ]; then
echo "Success! No formatting suggestions."
else
echo "Failure: stylish-haskell has some formatting suggestions:"
echo "$output"
exit 1
fi
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout telomare repository
uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
with:
name: telomare
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
extraPullNames: nix-community
- name: hlint linting
run: |
output=$(nix develop -c hlint . --no-exit-code)
if [ "$output" = "No hints" ]; then
echo "Success! No Hlint suggestions."
else
echo "Failure: Hlint has some suggestions for your commit"
echo "$output"
exit 1
fi
release:
if: ${{ (github.ref == 'refs/heads/master') && (github.repository == 'Stand-In-Language/stand-in-language') }}
needs: [tests, format, lint]
runs-on: ubuntu-latest
steps:
- name: Checkout telomare repository
uses: actions/checkout@v3
with:
repository: Stand-In-Language/stand-in-language
token: ${{ secrets.API_TOKEN_GITHUB }}
path: ./telomare
- name: Checkout telomare site repository
uses: actions/checkout@v3
with:
repository: Stand-In-Language/stand-in-language.github.io
token: ${{ secrets.API_TOKEN_GITHUB }}
path: ./stand-in-language.github.io
- uses: cachix/install-nix-action@v20
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
with:
name: telomare
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
extraPullNames: nix-community
- name: haddock build
run: |
ls
cd telomare
(nix develop -c cabal haddock --haddock-hyperlink-source) > ../haddock-output
echo OK Haddock build
- name: haddock copy
run: |
ls
# Check if the file exists
if [ ! -e haddock-output ]; then
echo "Error: File 'haddock-output' does not exist."
exit 1
fi
# Check if the file is empty
if [ ! -s haddock-output ]; then
echo "Error: File 'haddock-output' is empty."
exit 1
fi
current_dir=$(pwd)
# takes the last line of the haddock-output and removes overlapping paths with
# the current directory and also takes away the file name at the end of the path
# N.b. this command depends on `cabal haddock --haddock-hyperlink-source` displaying
# the location of the documentation as the last line of its output
doc_loc=$(tail -n 1 haddock-output | sed "s|^$current_dir/\(.*\)/.*|\1|")
rm -rf stand-in-language.github.io/docs/haddock/
mkdir stand-in-language.github.io/docs/haddock/
cp -r "$doc_loc"/. stand-in-language.github.io/docs/haddock
- uses: EndBug/add-and-commit@v7
with:
message: 'haddock documentation automatically updated'
cwd: './stand-in-language.github.io/'
default_author: github_actions