forked from restyled-io/restyler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
110 lines (92 loc) · 2.88 KB
/
Makefile
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
# This PR has differences such that all Restylers known at the time I made it
# will run, making it a great test PR.
INTEGRATION_PULL_REQUEST ?= restyled-io/demo\#45
INTEGRATION_APP_ENV ?= dev
INTEGRATION_INSTALLATION_ID ?= 58920
INTEGRATION_RESTYLER_IMAGE ?= restyled/restyler
INTEGRATION_RESTYLER_TAG ?= :latest
INTEGRATION_RESTYLER_BUILD ?= 1
all: setup setup.lint setup.tools build lint test
.PHONY: setup
setup:
stack setup
stack build --dependencies-only --test --no-run-tests
.PHONY: setup.lint
setup.lint:
stack install --copy-compiler-tool hlint weeder
.PHONY: setup.tools
setup.tools:
stack install --copy-compiler-tool \
brittany \
fast-tags \
stylish-haskell
.PHONY: build
build:
stack build --pedantic --test --no-run-tests
.PHONY: lint
lint:
stack exec hlint app src test
stack exec weeder .
.PHONY: test
test:
stack build --test
.PHONY: watch
watch:
stack build --fast --pedantic --test --file-watch
.PHONY: image
image:
docker build \
--build-arg "REVISION=testing" \
--tag restyled/restyler \
.
.PHONY: test.integration
test.integration:
if [ "$(INTEGRATION_RESTYLER_BUILD)" -eq 1 ]; then \
$(MAKE) image && \
docker tag restyled/restyler \
$(INTEGRATION_RESTYLER_IMAGE)$(INTEGRATION_RESTYLER_TAG); \
fi
docker run -it --rm \
--env DEBUG=1 \
--env GITHUB_ACCESS_TOKEN=$$(cd ../ops && ./tools/get-access-token $(INTEGRATION_APP_ENV) $(INTEGRATION_INSTALLATION_ID)) \
--volume /tmp:/tmp \
--volume /var/run/docker.sock:/var/run/docker.sock \
$(INTEGRATION_RESTYLER_IMAGE)$(INTEGRATION_RESTYLER_TAG) \
--job-url https://example.com \
--color=always "$(INTEGRATION_PULL_REQUEST)"
RESTYLERS_VERSION ?=
.PHONY: restylers_version
restylers_version:
[ -n "$(RESTYLERS_VERSION)" ]
git stash --include-untracked || true
git checkout master
git pull --rebase
sed -i 's/^\(restylers_version: "\).*"$$/\1$(RESTYLERS_VERSION)"/' config/default.yaml
git commit config/default.yaml -m "Bump default restylers_version"
git push
AWS ?= aws --profile restyled-ci
DOC_ENVIRONMENT ?= prod
DOC_BUCKET = $(shell \
$(AWS) cloudformation describe-stacks \
--stack-name $(DOC_ENVIRONMENT)-docs \
--query 'Stacks[*].Outputs[?OutputKey==`BucketName`].OutputValue' \
--output text \
)
DOC_DISTRIBUTION_ID = $(shell \
$(AWS) cloudformation describe-stacks \
--stack-name $(DOC_ENVIRONMENT)-docs \
--query 'Stacks[*].Outputs[?OutputKey==`DistributionId`].OutputValue' \
--output text \
)
DOC_ROOT = $(shell stack path --local-doc-root)
DOC_S3_PREFIX = /restyler
.PHONY: docs
docs:
[ -n "$$STACK_WORK_DIR" ]
stack build --haddock
find "$$STACK_WORK_DIR" -type f -name '*.html' -exec \
sed -i 's|$(DOC_ROOT)|$(DOC_S3_PREFIX)|g' {} +
$(AWS) s3 sync --acl public-read --delete $(DOC_ROOT)/ \
s3://$(DOC_BUCKET)$(DOC_S3_PREFIX)/
$(AWS) cloudfront create-invalidation \
--distribution-id $(DOC_DISTRIBUTION_ID) --paths "$(DOC_S3_PREFIX)/*"