-
Notifications
You must be signed in to change notification settings - Fork 17
153 lines (131 loc) · 4.63 KB
/
test.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
name: Test, lint & build
on:
- push
jobs:
test:
runs-on: blacksmith-2vcpu-ubuntu-2204
services:
postgres:
image: postgres:15.1
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: iota_erp
ports:
- 5432:5432
options: >-
--hostname=erp_db
--health-cmd="pg_isready -U postgres -d iota_erp"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.23.2"
- name: Install golangci-lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0
golangci-lint version
- name: Install templ
run: |
go install github.com/a-h/templ/cmd/[email protected]
templ --help
- name: Install TailwindCSS
run: |
echo "Installing TailwindCSS for x64 architecture..."
mkdir -p downloaded
curl -sL -o downloaded/tailwindcss https://github.com/tailwindlabs/tailwindcss/releases/download/v3.4.15/tailwindcss-linux-x64
chmod +x downloaded/tailwindcss
echo "$PWD/downloaded" >> $GITHUB_PATH
- name: Verify TailwindCSS installation
run: |
tailwindcss -h
- name: Install PNPM
uses: pnpm/action-setup@v4
with:
version: 9
- name: Download Go dependencies
run: go mod download
- name: Wait for PostgreSQL to be ready
run: |
until pg_isready -h localhost -p 5432 -U postgres -d iota_erp; do
echo "Waiting for postgres..."
sleep 1
done
- name: Test generated files are up to date
run: |
go generate ./...
make generate
git diff --exit-code
- name: Run custom linter
run: make build-iota-linter && make run-iota-linter
- name: Check migrations collect idempotence
run: |
make migrate collect
git status --porcelain migrations/
if [ -n "$(git status --porcelain migrations/)" ]; then
echo "Error: make migrate collect produced changes, please run 'make migrate collect' and commit the changes"
git status --porcelain migrations/
exit 1
fi
- name: Test Makefile targets
# running migrations and seeds twice to verify that they are idempotent
run: |
make migrate up
make migrate up
make seed
make seed
make css
- name: Check SQL files are properly formatted
# Install pg_formatter and verify all SQL files are properly formatted
run: |
sudo apt-get update
sudo apt-get install -y pgformatter
# Create a temporary directory for formatted files
mkdir -p /tmp/formatted
# Format each SQL file and check for differences
find modules -name "*.sql" -type f | while read -r sqlfile; do
pg_format "$sqlfile" > "/tmp/formatted/$(basename "$sqlfile")"
if ! diff -q "$sqlfile" "/tmp/formatted/$(basename "$sqlfile")" > /dev/null; then
echo "Error: $sqlfile is not properly formatted"
diff "$sqlfile" "/tmp/formatted/$(basename "$sqlfile")"
exit 1
fi
done
echo "All SQL files are properly formatted"
- name: Run go vet && tests
run: |
make generate
git diff --exit-code
go vet ./...
go test -v ./...
- name: Cypress run
uses: cypress-io/github-action@v6
env:
SESSION_DURATION: 720h
DOMAIN: localhost
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: iota_erp
DB_USER: postgres
DB_PASSWORD: postgres
SID_COOKIE_KEY: sid
GO_APP_ENV: production
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
with:
record: true
working-directory: e2e
install-command: pnpm install
start: go run ../cmd/server/main.go
wait-on: 'http://localhost:3200'
browser: chrome
- name: Test database migrate down
# e2e tests require database to have the seed data. We can only down the migrations after cypress.
run: |
make migrate down