From 60fd41f11c2ee805f8c1195d707ac71e4ca95202 Mon Sep 17 00:00:00 2001 From: Graham Steffaniak Date: Fri, 15 Sep 2023 15:57:22 -0500 Subject: [PATCH] updated workflow --- .dockerignore | 2 +- .github/workflows/main.yaml | 77 ++++++++----------------------- Dockerfile | 1 + backend/go.mod | 2 +- backend/settings/settings_test.go | 6 +-- backend/storage/bolt/config.go | 2 +- frontend/package.json | 5 +- 7 files changed, 29 insertions(+), 66 deletions(-) diff --git a/.dockerignore b/.dockerignore index 41108087..4a013aa4 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -backend/database.db +backend/**.db backend/vendor/** frontend/dist/** frontend/node_modules/** \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 42ae7c60..e709d46b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,70 +1,31 @@ -name: main +name: main job on: push: branches: - - 'master' - tags: - - 'v*' + - 'main' + - 'v\d+.\d+.\d+' pull_request: - + branches: + - 'main' + - 'v\d+.\d+.\d+' jobs: -# linters - lint-frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - run: make lint-frontend - lint-backend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.20.1 - - run: make lint-backend - lint-commits: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - run: make lint-commits - lint: - runs-on: ubuntu-latest - needs: [lint-frontend, lint-backend, lint-commits] - steps: - - run: echo "done" - -# tests - test-frontend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '16' - - run: make test-frontend - test-backend: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 - with: - go-version: 1.20.1 - - run: make test-backend test: runs-on: ubuntu-latest - needs: [test-frontend, test-backend] steps: - - run: echo "done" - + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.21.1 + - run: cd backend && go test -race -v ./... + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: 1.21.1 + - run: go fmt # release release: runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 070266d6..5df9a358 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ RUN npm run build FROM golang:1.21-alpine as base WORKDIR /app COPY ./backend ./ +RUN go get -u golang.org/x/net RUN go build -ldflags="-w -s" -o filebrowser . FROM alpine:latest diff --git a/backend/go.mod b/backend/go.mod index 107622c5..83bc14f3 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -1,6 +1,6 @@ module github.com/gtsteffaniak/filebrowser -go 1.21.0 +go 1.21 require ( github.com/asdine/storm/v3 v3.2.1 diff --git a/backend/settings/settings_test.go b/backend/settings/settings_test.go index 7eefacd7..e2c192ee 100644 --- a/backend/settings/settings_test.go +++ b/backend/settings/settings_test.go @@ -9,8 +9,7 @@ import ( ) func TestConfigLoadChanged(t *testing.T) { - configYml = "./testingConfig.yaml" - yamlData := loadConfigFile() + yamlData := loadConfigFile("./testingConfig.yaml") // Marshal the YAML data to a more human-readable format newConfig := setDefaults() GlobalConfiguration := setDefaults() @@ -26,8 +25,7 @@ func TestConfigLoadChanged(t *testing.T) { } func TestConfigLoadSpecificValues(t *testing.T) { - configYml = "./testingConfig.yaml" - yamlData := loadConfigFile() + yamlData := loadConfigFile("./testingConfig.yaml") // Marshal the YAML data to a more human-readable format newConfig := setDefaults() GlobalConfiguration := setDefaults() diff --git a/backend/storage/bolt/config.go b/backend/storage/bolt/config.go index cb4914c6..b9f293da 100644 --- a/backend/storage/bolt/config.go +++ b/backend/storage/bolt/config.go @@ -20,7 +20,7 @@ func (s settingsBackend) Save(set *settings.Settings) error { func (s settingsBackend) GetServer() (*settings.Server, error) { server := &settings.Server{ - Port: 8080, + Port: 8080, NumImageProcessors: 1, } return server, get(s.db, "server", server) diff --git a/frontend/package.json b/frontend/package.json index ce75e1ca..1c37e8fb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -6,7 +6,10 @@ "serve": "vue-cli-service serve", "build": "vue-cli-service build", "fix": "npx vue-cli-service lint", - "watch": "vue-cli-service build --watch" + "watch": "vue-cli-service build --watch", + "lint": "eslint --ext .vue,.js src/", + "lint:fix": "eslint --ext .vue,.js --fix src/", + "format": "prettier --write ." }, "dependencies": { "ace-builds": "^1.4.7",