Skip to content

Commit

Permalink
feat(ci): add workflow to test client
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaut-gauvin committed Jun 24, 2024
1 parent b025ee5 commit eade624
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 25 deletions.
18 changes: 16 additions & 2 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on: # yamllint disable-line rule:truthy
- ".github/workflows/qa.yml"
- "go.*"
- "**.go"
- "client/**"
push:
branches: [main]

Expand All @@ -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
Expand All @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
extends: default

ignore: |
dist/
test/
venv/

rules:
comments:
Expand Down
9 changes: 3 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions client/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
File renamed without changes
18 changes: 3 additions & 15 deletions client/src/models/trivy.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,8 +117,8 @@ export interface Cvss {
}

export interface Ghsa {
V3Vector: string;
V3Score: number;
V3Vector?: string;
V3Score?: number;
}

export interface Nvd {
Expand Down
3 changes: 2 additions & 1 deletion client/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -41,7 +42,7 @@

<div class="layout">
<div class="navbar">
<img src="./logo.png" alt="dib logo" />
<img src={Logo} alt="dib logo" />
<ul>
<li>
<a href="/" class:current={$page.url.pathname === '/'}>Overview</a>
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/+layout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const prerender = true;
export const csr = true;
export const ssr = false;
export const trailingSlash = 'never';
export const trailingSlash = 'always';

0 comments on commit eade624

Please sign in to comment.