From 7ccd48ad79797e649ebf30bbafa898bcbe6eac7d Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 3 Sep 2022 19:06:55 -0800 Subject: [PATCH] ci: end-to-end CI testing (#1) * do end-to-end testing * set node version * build then start * remove test restrictions * panic if mime type fails * use timeout --- .github/workflows/frontend.yaml | 23 ++++++++++++++--------- .github/workflows/go.yaml | 5 +---- Taskfile.yml | 3 ++- backend/app/api/routes.go | 11 +++++++++-- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/frontend.yaml b/.github/workflows/frontend.yaml index 91a85ba..34abb7d 100644 --- a/.github/workflows/frontend.yaml +++ b/.github/workflows/frontend.yaml @@ -1,19 +1,25 @@ on: push: branches: [main] - paths: - - "**.ts" - - "**.vue" pull_request: branches: [main] - paths: - - "**.ts" - - "**.vue" jobs: Frontend: runs-on: ubuntu-latest steps: + - name: Install Task + uses: arduino/setup-task@v1 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - uses: actions/setup-node@v3 + with: + node-version: 18 + - uses: pnpm/action-setup@v2.2.2 with: version: 6.0.2 @@ -27,6 +33,5 @@ jobs: run: pnpm install working-directory: frontend - - name: Vitest - run: pnpm test:ci - working-directory: frontend + - name: Run Integration Tests + run: task test:integration diff --git a/.github/workflows/go.yaml b/.github/workflows/go.yaml index f07b85d..c6ba7c2 100644 --- a/.github/workflows/go.yaml +++ b/.github/workflows/go.yaml @@ -3,12 +3,8 @@ name: Go Build/Test on: push: branches: [main] - paths: - - "**.go" pull_request: branches: [main] - paths: - - "**.go" jobs: Go: @@ -31,6 +27,7 @@ jobs: version: latest # Optional: working directory, useful for monorepos + timeout: 5m working-directory: backend - name: Build API diff --git a/Taskfile.yml b/Taskfile.yml index 8aca42a..cc215da 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -33,7 +33,8 @@ tasks: test:integration: cmds: - - cd backend && go run ./app/api/ & + - cd backend && go build ./app/api + - backend/api & - sleep 5 - cd frontend && pnpm run test:ci silent: true diff --git a/backend/app/api/routes.go b/backend/app/api/routes.go index a2b34f3..46b8610 100644 --- a/backend/app/api/routes.go +++ b/backend/app/api/routes.go @@ -107,8 +107,15 @@ func (a *app) LogRoutes(r *chi.Mux) { var ErrDir = errors.New("path is dir") func init() { - mime.AddExtensionType(".js", "application/javascript") - mime.AddExtensionType(".mjs", "application/javascript") + err := mime.AddExtensionType(".js", "application/javascript") + if err != nil { + panic(err) + } + + err = mime.AddExtensionType(".mjs", "application/javascript") + if err != nil { + panic(err) + } } func tryRead(fs embed.FS, prefix, requestedPath string, w http.ResponseWriter) error {