-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
113 lines (99 loc) · 3.36 KB
/
Taskfile.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
version: "3"
tasks:
dev:
desc: Start the app in dev mode with live-reloading.
env:
BANTERBUS_LOG_LEVEL: debug
cmds:
- podman-compose up -d
- task: watch
- air
lint:
desc: Runs the linter.
cmds:
- golangci-lint run ./...
format:
desc: Runs the formatter.
env:
LOCATIONS: "./internal/ ./tests/ main.go"
cmds:
- goimports -local gitlab.com/hmajid2301/banterbus -w $LOCATIONS
- golines -m 120 -w $LOCATIONS
tests:
desc: Runs all the tests.
cmds:
- gotestsum
tests:unit:
desc: Runs all the unit tests.
cmds:
- gotestsum --format testname --hide-summary=skipped -- -cover -skip '^TestIntegration' ./internal/... {{.CLI_ARGS}}
tests:integration:
desc: Runs all the integration tests.
cmds:
- gotestsum --format testname --hide-summary=skipped -- -cover -run ^TestIntegration ./internal/... {{.CLI_ARGS}}
tests:e2e:
desc: Runs e2e tests with playwright.
env:
BANTERBUS_LOG_LEVEL: info
cmds:
- gotestsum --format testname --hide-summary=skipped --rerun-fails --packages="./tests/e2e" -- -cover {{.CLI_ARGS}}
tests:e2e:quiet:
desc: Runs e2e tests with playwright without any logging as this can be super verbose.
env:
LOG_DISABLED: true
HEADLESS: false
cmds:
- gotestsum --format dots -- ./tests/e2e/... {{.CLI_ARGS}}
coverage:
desc: show coverage
cmds:
- go tool covdata textfmt -i="coverage" -o combined-coverage.txt
- go tool cover -func=combined-coverage.txt -o coverage.xml
watch:
desc: Watch for file changes and run commands, i.e. generate templates or tailwindcss
env:
TEMPL_EXPERIMENT: rawgo
cmds:
- templ generate -watch --proxy="http://localhost:8080" --open-browser=true &
- tailwindcss --watch=always -i ./static/css/tailwind.css -o ./static/css/styles.css --minify &
# TODO: do we want to add watch commands for the following?
# - mockery --all
# - sqlc generate
generate:
desc: Generates all the code needed for the project i.e. sqlc, templ & tailwindcss
env:
TEMPL_EXPERIMENT: rawgo
cmds:
- mockery --all
- templ generate
- tailwindcss -i ./static/css/tailwind.css -o ./static/css/styles.css --minify
- sqlc generate
- gomod2nix generate
- task: format
release:
desc: Release the web app.
cmds:
- goreleaser release --clean --verbose
docker:publish:
desc: Build and publish the Docker image
env:
LOCAL_IMAGE: banterbus
FLAKE_TARGET: container
IMMUTABLE: "true"
cmds:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- |
if [ "$IMMUTABLE" = "true" ]; then
if docker pull $IMAGE; then
echo "Image with tag $IMAGE_TAG already exists. Failing the pipeline."
exit 1
fi
fi
- nix build .#${FLAKE_TARGET}
- docker load < result
- docker image tag $LOCAL_IMAGE:latest $IMAGE
- docker push $IMAGE
ci:local:
desc: Run gitlab ci locally
cmds:
- job=$(yq 'keys | .[] | select(. != "image" and . != "workflow" and . != "stages" and . != "variables" and . != "default" and (. | test("^[^.]")) )' .gitlab-ci.yml | gum filter --placeholder "Select a job...") && gitlab-ci-local --variable CI_REGISTRY=registry.gitlab.com "$job"