Skip to content

Commit 9380072

Browse files
authored
Merge pull request #90 from imba28/feat/vue-app
Feat/vue app
2 parents b9539ea + 208db27 commit 9380072

File tree

163 files changed

+48731
-13689
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+48731
-13689
lines changed

.babelrc

Lines changed: 0 additions & 13 deletions
This file was deleted.

.dockerignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
_mongo-volume
22
.git
3-
dist
3+
/dist
44
node_modules
5-
public/dist
5+
public
6+
7+
/config.*

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
6+
[*.{js,vue,json}]
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 2
10+
11+
[Makefile]
12+
indent_style = tab

.eslintrc.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,27 @@ module.exports = {
22
'env': {
33
'browser': true,
44
'es2021': true,
5+
'node': true,
6+
'jest/globals': true,
57
},
8+
'plugins': ['jest'],
69
'extends': [
10+
'eslint:recommended',
711
'google',
12+
'plugin:vue/recommended',
813
],
914
'parserOptions': {
1015
'ecmaVersion': 12,
1116
'sourceType': 'module',
1217
},
13-
'rules': {},
18+
'rules': {
19+
'max-len': ['error', {'code': 120}],
20+
'no-debugger': [process.env.NODE_ENV === 'production' ? 'error' : 'off'],
21+
'jest/no-disabled-tests': 'warn',
22+
'jest/no-focused-tests': 'error',
23+
'jest/no-identical-title': 'error',
24+
'jest/prefer-to-have-length': 'warn',
25+
'jest/valid-expect': 'error',
26+
},
27+
'ignorePatterns': ['assets/openapi/**/*.js', 'jest.config.js', 'vue.config.js'],
1428
};

.github/workflows/release.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
tags:
66
- 'v*'
77

8+
env:
9+
go_version: 1.18
10+
node_version: 14
11+
812
jobs:
913
docker-release:
1014
runs-on: ubuntu-latest
@@ -60,17 +64,17 @@ jobs:
6064

6165
- uses: actions/setup-node@v3
6266
with:
63-
node-version: '16'
67+
node-version: ${{ env.node_version }}
6468
- run: npm ci
6569
- run: npm run build
6670

6771
- name: Set up Go
6872
uses: actions/setup-go@v3
6973
with:
70-
go-version: 1.17
74+
go-version: ${{ env.go_version }}
7175
- name: Build backend
7276
run: |
73-
sed -i "s/dev-build/${{ steps.get_version.outputs.VERSION }}/" internal/template/files/includes/footer.html &&
77+
sed -i "s/dev-build/${{ steps.get_version.outputs.VERSION }}/" assets/App.vue
7478
make bundle
7579
7680
- name: Copy docker-compose.yml

.github/workflows/test.yml

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,59 @@ on:
66
pull_request:
77
branches: [ 'master' ]
88

9+
env:
10+
go_version: 1.18
11+
node_version: 14
12+
13+
DATABASE_USER: root
14+
DATABASE_PASSWORD: example
15+
DATABASE_HOST: 127.0.0.1
16+
917
jobs:
18+
openapi-code-generator:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 1
24+
- run: make openapi-spec
25+
26+
- uses: actions/upload-artifact@v3
27+
with:
28+
name: openapi-files
29+
path: |
30+
assets/openapi
31+
pkg/openapi
32+
if-no-files-found: error
33+
1034
frontend:
35+
needs: openapi-code-generator
1136
runs-on: ubuntu-latest
1237
steps:
1338
- uses: actions/checkout@v3
1439
with:
1540
fetch-depth: 1
1641
- uses: actions/setup-node@v3
1742
with:
18-
node-version: '16'
43+
node-version: ${{ env.node_version }}
44+
- uses: actions/download-artifact@v3
45+
with:
46+
name: openapi-files
47+
path: .
48+
1949
- run: make lint-frontend
2050
- run: make frontend
2151

52+
- run: make test-frontend
53+
2254
backend:
55+
needs: openapi-code-generator
2356
runs-on: ubuntu-latest
2457
strategy:
2558
fail-fast: false
2659
matrix:
2760
mongodb_image: ['mongo:4', 'mongo:5']
2861

29-
env:
30-
DATABASE_USER: root
31-
DATABASE_PASSWORD: example
32-
DATABASE_HOST: 127.0.0.1
33-
3462
services:
3563
mongodb:
3664
env:
@@ -44,10 +72,16 @@ jobs:
4472
- uses: actions/checkout@v3
4573
with:
4674
fetch-depth: 1
75+
76+
- uses: actions/download-artifact@v3
77+
with:
78+
name: openapi-files
79+
path: .
80+
4781
- name: Set up Go
4882
uses: actions/setup-go@v3
4983
with:
50-
go-version: 1.17
84+
go-version: ${{ env.go_version }}
5185

5286
- name: Test
5387
run: make test
@@ -57,3 +91,55 @@ jobs:
5791

5892
- name: Print coverage
5993
run: go tool cover -func cover.out | tail -n 1 | awk '{print $3}'
94+
95+
e2e:
96+
needs: [backend, frontend]
97+
runs-on: ubuntu-latest
98+
99+
strategy:
100+
fail-fast: false
101+
matrix:
102+
mongodb_image: [ 'mongo:4', 'mongo:5' ]
103+
104+
services:
105+
mongodb:
106+
env:
107+
MONGO_INITDB_ROOT_USERNAME: root
108+
MONGO_INITDB_ROOT_PASSWORD: example
109+
image: ${{ matrix.mongodb_image }}
110+
ports:
111+
- 27017:27017
112+
113+
steps:
114+
- uses: actions/checkout@v3
115+
with:
116+
fetch-depth: 1
117+
118+
- uses: actions/download-artifact@v3
119+
with:
120+
name: openapi-files
121+
path: .
122+
123+
- uses: actions/setup-node@v3
124+
with:
125+
node-version: ${{ env.node_version }}
126+
127+
- name: Set up Go
128+
uses: actions/setup-go@v3
129+
with:
130+
go-version: ${{ env.go_version }}
131+
132+
- name: Run e2e suite
133+
env:
134+
SPOTIFY_ID: ${{ secrets.SPOTIFY_ID }}
135+
SPOTIFY_SECRET: ${{ secrets.SPOTIFY_SECRET }}
136+
GENIUS_API_TOKEN: ${{ secrets.GENIUS_API_TOKEN }}
137+
run: make test-e2e
138+
139+
- uses: actions/upload-artifact@v3
140+
if: failure()
141+
with:
142+
name: cypress-files
143+
path: |
144+
tests/e2e/screenshots
145+
tests/e2e/videos

.gitignore

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
_mongo-volume
2-
dist
32
cover.html
43
cover.out
54
.idea
6-
spolyr
7-
spolyr.exe
8-
node_modules
5+
/spolyr
6+
/spolyr.exe
7+
node_modules
8+
public
9+
pkg/openapi
10+
assets/openapi
11+
assets/coverage
12+
13+
!/**/.gitkeep
14+
15+
tests/e2e/screenshots
16+
tests/e2e/videos
17+
18+
/config.*
19+
/dist/

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": true
4+
},
5+
"eslint.validate": ["javascript", "vue"]
6+
}
7+

Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# api build
2-
FROM golang:1.17 as builder
2+
FROM golang:1.18 as builder
33

44
ARG BUILD_NUMBER=dev
55

@@ -11,11 +11,11 @@ COPY go.sum .
1111
RUN go mod download
1212

1313
COPY . .
14-
RUN sed -i "s/dev-build/${BUILD_NUMBER}/" internal/template/files/includes/footer.html && \
14+
RUN sed -i "s/dev-build/${BUILD_NUMBER}/" assets/App.vue && \
1515
make build-linux
1616

1717
# frontend build
18-
FROM node:16-alpine as frontend_builder
18+
FROM node:14-alpine as frontend_builder
1919

2020
WORKDIR /build
2121

@@ -38,7 +38,7 @@ USER spolyr
3838

3939
WORKDIR /app
4040
COPY --from=builder --chown=spolyr:spolyr /build/spolyr .
41-
COPY --from=builder --chown=spolyr:spolyr /build/public public
42-
COPY --from=frontend_builder --chown=spolyr:spolyr /build/public/dist public/dist
41+
COPY --from=frontend_builder --chown=spolyr:spolyr /build/public public
4342

44-
CMD ["/app/spolyr"]
43+
ENTRYPOINT ["/app/spolyr"]
44+
CMD ["web"]

Makefile

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.PHONY: all clean bundle build test frontend
22

33
build-linux:
4-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -tags netgo -o spolyr cmd/main.go
4+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -a -tags netgo -o spolyr ./main.go
55

66
build-windows:
7-
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -a -tags netgo -o spolyr.exe cmd/main.go
7+
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -a -tags netgo -o spolyr.exe ./main.go
88

99
build: build-linux build-windows
1010

@@ -14,18 +14,26 @@ clean:
1414
rm -f spolyr-linux-amd64.tar.gz
1515
rm -f spolyr-windows-amd64.tar.gz
1616
rm -rf dist
17+
rm -rf pkg/openapi
1718

1819
bundle: build
1920
mkdir -p ./dist
2021
tar -czvf dist/spolyr-linux-amd64.tar.gz public spolyr
2122
tar -czvf dist/spolyr-windows-amd64.tar.gz public spolyr.exe
2223

2324
test:
24-
DATABASE_USER=root DATABASE_PASSWORD=example DATABASE_HOST=127.0.0.1 go test -coverprofile cover.out ./internal/...
25+
DATABASE_USER=root DATABASE_PASSWORD=example DATABASE_HOST=127.0.0.1 go test -coverprofile cover.out ./pkg/...
2526
go tool cover -html=cover.out -o cover.html
2627

2728
test-units:
28-
go test -short ./internal/...
29+
go test -short ./pkg/...
30+
31+
test-e2e: build-linux frontend
32+
DATABASE_USER=root DATABASE_PASSWORD=example DATABASE_HOST=127.0.0.1 ./spolyr fixtures
33+
DATABASE_USER=root DATABASE_PASSWORD=example DATABASE_HOST=127.0.0.1 ./spolyr web > /tmp/backend.log 2>&1 &
34+
npm run test:e2e:ci:chromium
35+
killall spolyr
36+
cat /tmp/backend.log
2937

3038
coverage: test
3139
go tool cover -func cover.out | tail -n 1 | awk '{print $3}'
@@ -37,4 +45,16 @@ frontend: node_modules
3745
npm run build
3846

3947
lint-frontend: node_modules
40-
npm run lint
48+
npm run lint
49+
50+
test-frontend: node_modules
51+
npm run test:unit
52+
53+
openapi-spec:
54+
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -g go-server -i /local/oapi-spec.yaml -o /local/pkg/openapi --additional-properties=outputAsLibrary=true,onlyInterfaces=true,sourceFolder=openapi,addResponseHeaders=true
55+
sudo chown -R $(USER): pkg/openapi/
56+
sed -i -e 's/"github.com\/gorilla\/mux"//g' pkg/openapi/openapi/api_auth.go
57+
sed -i -e 's/"encoding\/json"//g' pkg/openapi/openapi/api_import.go
58+
sed -i -e 's/"encoding\/json"//g' -e 's/"github.com\/gorilla\/mux"//g' pkg/openapi/openapi/api_playlists.go
59+
docker run --rm -v "${PWD}/oapi-spec.yaml:/local/oapi-spec.yaml" -v "${PWD}/assets/openapi/:/local/assets/openapi/src" openapitools/openapi-generator-cli generate -g javascript -i /local/oapi-spec.yaml -o /local/assets/openapi --additional-properties=usePromises=true,moduleName=@/openapi --global-property models,modelTests=false --global-property apis,apiTests=false --global-property supportingFiles
60+

0 commit comments

Comments
 (0)