File tree 3 files changed +83
-9
lines changed
3 files changed +83
-9
lines changed Original file line number Diff line number Diff line change 8
8
steps :
9
9
- checkout
10
10
11
+ - run :
12
+ name : Make a recent eu binary available to the build
13
+ command : |
14
+ cd ci
15
+ pipenv install
16
+ pipenv run python fetch.py /usr/local/bin
17
+ eu --version
18
+
11
19
- restore_cache :
12
20
keys :
13
21
- cache-{{ checksum "stack.yaml" }}-{{ checksum "package.yaml" }}
38
46
- ~/.stack
39
47
key : cache-{{ checksum "stack.yaml" }}-{{ checksum "package.yaml" }}
40
48
49
+ - run :
50
+ name : Update build / release details in package.yaml
51
+ command : |
52
+ export OSTYPE=$(uname)
53
+ export HOSTTYPE=$(uname -m)
54
+ eu package=package.yaml ci/build.eu > new-package.yaml
55
+ mv -f new-package.yaml package.yaml
56
+ echo --- replaced package.yaml ---
57
+ cat package.yaml
58
+
41
59
- run :
42
60
name : Build, run unit tests with coverage
43
61
command : stack build --fast --pedantic --no-terminal --test --coverage
49
67
hlint .
50
68
51
69
- run :
52
- name : Build with no coverage instrumentation
70
+ name : Build without coverage
53
71
command : stack build --pedantic --no-terminal --ghc-options="-O2"
54
72
73
+ - run :
74
+ name : Check build metadata for generated executable
75
+ command : stack exec eu -- -e 'eu.build'
76
+
55
77
- persist_to_workspace :
56
78
root : .stack-work
57
79
paths :
Original file line number Diff line number Diff line change 13
13
version: package.version
14
14
str.match-with("(\d+)\.(\d+)\.([^.]+)\.([^.]+)")
15
15
drop(1)
16
- with-keys([:major, :minor, :revision , :build])
16
+ with-keys([:major, :minor, :patch , :build])
17
17
18
18
build: {
19
19
20
20
` "Circle build number"
21
- number: io.env lookup-or(:CIRCLE_BUILD_NUM, version.revision )
21
+ number: io.env lookup-or(:CIRCLE_BUILD_NUM, version.patch )
22
22
23
23
` "SHA1 of the repo commit we're building"
24
24
commit: io.env lookup-or(:CIRCLE_SHA1, "working-copy")
25
25
26
26
` "URL of build"
27
27
url: io.env lookup-or(:CIRCLE_BUILD_URL, "(none)")
28
28
29
+ ` "Architecture of build environment"
30
+ arch: io.env lookup-alts([:HOSTTYPE, :_system_arch], "unknown")
31
+
32
+ ` "Architecture of build environment"
33
+ os: io.env lookup-alts([:OSTYPE, :_system_name], "unknown")
34
+
35
+ ` "Seconds since epoch at eu build time"
36
+ epoch-time: io.epoch-time
29
37
}
30
38
31
39
new-version: [version.major,
32
40
version.minor,
33
- build.number ,
34
- str.of(io.epoch-time) ] str.join-on(".")
41
+ version.patch ,
42
+ build.number ] str.join-on(".")
35
43
36
44
` :main
37
45
main: package {
38
46
version: new-version
39
- eu-build: {
40
- commit: build.commit
41
- url: build.url
42
- }
47
+ eu-build: build
43
48
}
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+
3
+ import sys
4
+ from pathlib import Path
5
+ import re
6
+ import os
7
+ import subprocess
8
+ import tarfile
9
+ from github3 import login
10
+
11
+ def fetch (bindir ):
12
+
13
+ """ Download the latest binary release for this platform to `bindir`. """
14
+
15
+ token = os .environ ['GITHUB_API_TOKEN' ]
16
+ if not token :
17
+ raise EnvironmentError ("No Github API Token available" )
18
+
19
+ gh = login (token = token )
20
+ r = gh .repository ("curvelogic" , "eucalypt-hs" )
21
+
22
+ release = r .latest_release ()
23
+ asset = [a for a in release .assets () if "linux" in a .name ][0 ]
24
+
25
+ print ("Downloading {}" .format (asset .name ))
26
+ asset .download ()
27
+
28
+ print ("Extracting {}" .format (asset .name ))
29
+ with tarfile .open (asset .name , "r:gz" ) as tar :
30
+ files = [f for f in tar if f .isreg ()]
31
+ print (" - extracting {}" .format (f .name for f in files ))
32
+ tar .extractall (members = files )
33
+ print (" - moving to ~/local/bin" )
34
+ for f in files :
35
+ os .rename (f .name , bindir / Path (f .name ).name )
36
+
37
+ def main (args ):
38
+
39
+ if len (args ) > 1 :
40
+ bindir = Path (args [1 ])
41
+ else :
42
+ bindir = Path .home () / "bin"
43
+
44
+ fetch (bindir )
45
+
46
+ if __name__ == '__main__' :
47
+ main (sys .argv )
You can’t perform that action at this time.
0 commit comments