From eade624d292f02e591c6f066e917474dabf9a319 Mon Sep 17 00:00:00 2001 From: Thibaut Gauvin Date: Mon, 24 Jun 2024 01:39:15 +0200 Subject: [PATCH] feat(ci): add workflow to test client --- .github/workflows/qa.yml | 18 ++++++++++++++++-- .github/workflows/release.yml | 9 +++++++++ .yamllint | 2 ++ Makefile | 9 +++------ client/.nvmrc | 1 + client/{static => src/lib/assets}/logo.png | Bin client/src/models/trivy.interface.ts | 18 +++--------------- client/src/routes/+layout.svelte | 3 ++- client/src/routes/+layout.ts | 2 +- 9 files changed, 37 insertions(+), 25 deletions(-) create mode 100644 client/.nvmrc rename client/{static => src/lib/assets}/logo.png (100%) diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 27174a8f0..637e39326 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -7,6 +7,7 @@ on: # yamllint disable-line rule:truthy - ".github/workflows/qa.yml" - "go.*" - "**.go" + - "client/**" push: branches: [main] @@ -16,19 +17,31 @@ permissions: checks: write jobs: - lint: - name: Run linters + linter_go: + name: Run golangci-lint runs-on: ubuntu-latest steps: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version-file: "go.mod" + - run: mkdir -p client/build && touch client/build/sample.txt # Simulate client build - uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64 # v6.0.1 with: # renovate: datasource=github-releases depName=golangci/golangci-lint version: v1.57.2 + linter_js: + name: Run ESLint & Prettier + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version-file: 'client/.nvmrc' + - run: NODE_ENV=CI npm -C client install + - run: NODE_ENV=CI npm -C client lint + tests: name: Run tests runs-on: ubuntu-latest @@ -38,6 +51,7 @@ jobs: with: go-version-file: "go.mod" - uses: tlylt/install-graphviz@b2201200d85f06f0189cb74d9b69208504cf12cd # v1.0.0 + - run: mkdir -p client/build && touch client/build/sample.txt # Simulate client build - run: go test -v -race -covermode=atomic -coverprofile=coverage.out ./... - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9afccfab8..77df17aed 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,15 @@ jobs: - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6 with: fetch-depth: 0 + + # Bootstrap Svelte client + - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + with: + node-version-file: 'client/.nvmrc' + - run: NODE_ENV=CI npm -C client install + - run: NODE_ENV=production npm -C client run build + + # Compile Go bin - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 with: go-version-file: "go.mod" diff --git a/.yamllint b/.yamllint index 7b3d5d0cd..056cbcf39 100644 --- a/.yamllint +++ b/.yamllint @@ -2,7 +2,9 @@ extends: default ignore: | + dist/ test/ + venv/ rules: comments: diff --git a/Makefile b/Makefile index 16ffd3afc..506373a02 100644 --- a/Makefile +++ b/Makefile @@ -57,12 +57,9 @@ fmt: ## Run `go fmt` on all files ## client.artifact: ## Build client artifact (Svelte static site) - ( \ - cd client; \ - rm -rf build; \ - NODE_ENV=CI npm install; \ - NODE_ENV=production npm run build; \ - ) + rm -rf client/build + NODE_ENV=CI npm -C client install + NODE_ENV=production npm -C client run build client.qa: client.lint ## Run client qa diff --git a/client/.nvmrc b/client/.nvmrc new file mode 100644 index 000000000..790e1105f --- /dev/null +++ b/client/.nvmrc @@ -0,0 +1 @@ +v20.10.0 diff --git a/client/static/logo.png b/client/src/lib/assets/logo.png similarity index 100% rename from client/static/logo.png rename to client/src/lib/assets/logo.png diff --git a/client/src/models/trivy.interface.ts b/client/src/models/trivy.interface.ts index b26f9fc7f..66144ff6f 100644 --- a/client/src/models/trivy.interface.ts +++ b/client/src/models/trivy.interface.ts @@ -46,23 +46,11 @@ export interface Rootfs { export interface Config { Cmd: string[]; Env: string[]; - Labels: Labels; + Labels: string[]; User: string; Shell: string[]; } -export interface Labels { - name: string; - 'org.opencontainers.image.base.name': string; - 'org.opencontainers.image.created': string; - 'org.opencontainers.image.ref.name': string; - 'org.opencontainers.image.revision': string; - 'org.opencontainers.image.source': string; - 'org.opencontainers.image.title': string; - 'org.opencontainers.image.url': string; - 'org.opencontainers.image.version': string; -} - export interface Result { Target: string; Class: string; @@ -129,8 +117,8 @@ export interface Cvss { } export interface Ghsa { - V3Vector: string; - V3Score: number; + V3Vector?: string; + V3Score?: number; } export interface Nvd { diff --git a/client/src/routes/+layout.svelte b/client/src/routes/+layout.svelte index ea49146ef..63f5ea0ec 100644 --- a/client/src/routes/+layout.svelte +++ b/client/src/routes/+layout.svelte @@ -2,6 +2,7 @@ import { page } from '$app/stores'; import { onMount } from 'svelte'; import { imagesStore, reportDataStore } from '$stores/report.ts'; + import Logo from '$lib/assets/logo.png'; onMount(() => { // "dib_images" is set from included "map.js" generated file @@ -41,7 +42,7 @@