Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 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,28 +17,41 @@ permissions:
checks: write

jobs:
lint:
name: Run linters
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 run lint

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

tests:
name: Run tests
name: Run Go tests
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"
- 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
10 changes: 10 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ 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: sed -i 's/unreleased/${{ github.ref_name }}/' client/package.json
- 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
56 changes: 47 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@ help: ## Display this message
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | \
sed -e 's/\[32m##/[33m/'

artifact: ## Generate binary in dist folder
client/build: client.artifact

artifact: client/build ## Generate binary in dist folder
goreleaser build --clean --snapshot --single-target

install: ## Generate binary and copy it to $GOPATH/bin (equivalent to go install)
install: client/build ## Generate binary and copy it to $GOPATH/bin (equivalent to go install)
goreleaser build --clean --snapshot --single-target -o $(GOPATH)/bin/dib

build: ## Build the CLI binary.
CGO_ENABLED=0 go build -o ./dist/dib ./cmd

docs: build
./dist/dib docgen

##
## ----------------------
## Q.A
## ----------------------
##

qa: lint test ## Run all QA process
qa: lint test fmt ## Run Golang QA

lint: ## Lint source code
golangci-lint run -v
Expand All @@ -53,3 +49,45 @@ test: ## Run tests

fmt: ## Run `go fmt` on all files
find -name '*.go' -exec gofmt -w -s '{}' ';'

##
## ----------------------
## Client
## ----------------------
##

client.artifact: ## Build client artifact (Svelte static site)
rm -rf client/build
# sed -i 's/unreleased/$(shell git describe --tags --abbrev=0)-next/' client/package.json
NODE_ENV=CI npm -C client install
NODE_ENV=production npm -C client run build

client.qa: client.lint ## Run client qa

client.lint: ## Run client linter (eslint & prettier)
cd client && npm run lint

##
## ----------------------
## Doc
## ----------------------
##

.PHONY: docs
docs: ## Compile dib bin then regen CLI doc
mkdir -p client/build && touch client/build/sample.txt
CGO_ENABLED=0 go build -o ./dist/dib ./cmd
./dist/dib docgen

doc.serve: docs ## Start dib static doc dev server
( \
. venv/bin/activate; \
mkdocs serve; \
)

doc.init: ## Init static doc python deps
( \
python3 -m virtualenv -p /usr/bin/python3 venv; \
. venv/bin/activate; \
pip install -r requirements.txt; \
)
21 changes: 21 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
node_modules

# Output
.output
.vercel
/.svelte-kit
/build

# OS
.DS_Store
Thumbs.db

# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions client/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
1 change: 1 addition & 0 deletions client/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.10.0
5 changes: 5 additions & 0 deletions client/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fixtures
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
8 changes: 8 additions & 0 deletions client/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}
24 changes: 24 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Dib client

Dib client is a Svelte app that we compile as static-site to embed in final Dib Go binary.

It is used as base to generate "dib build" html report outputs.

see `client.go` if you are curious.

## Developing

```bash
npm install
npm run dev
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.
10 changes: 10 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Package client expose an embed filesystem to hold our Svelte static site build.
// It is used as base to generate "dib build" html report outputs.
package client

import "embed"

const AssetsRootDir = "build"

//go:embed build/*
var AssetsFS embed.FS
33 changes: 33 additions & 0 deletions client/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import js from '@eslint/js';
import ts from 'typescript-eslint';
import svelte from 'eslint-plugin-svelte';
import prettier from 'eslint-config-prettier';
import globals from 'globals';

/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
js.configs.recommended,
...ts.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
files: ['**/*.svelte'],
languageOptions: {
parserOptions: {
parser: ts.parser
}
}
},
{
ignores: ['.svelte-kit/', 'dist/', 'build/', 'fixtures/']
}
];
Binary file added client/fixtures/report-data/dev/dag.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions client/fixtures/report-data/dev/data/app-curl/docker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#0 building with "default" instance using docker driver

#1 [1/2] FROM registry.localhost/base-debian-bookworm:dev-butter-social-twenty-whiskey
#1 DONE 0.0s

#2 [internal] load build definition from Dockerfile
#2 transferring dockerfile: 199B done
#2 DONE 0.0s

#3 [internal] load metadata for registry.localhost/base-debian-bookworm:dev-butter-social-twenty-whiskey
#3 DONE 0.0s

#4 [internal] load .dockerignore
#4 transferring context: 2B done
#4 DONE 0.0s

#5 exporting to image
#5 exporting layers done
#5 writing image sha256:94895e8f24bf9c30598bb187bca13bcd927a640d4160c89f48fa24e3ca3e3a73 done
#5 naming to registry.localhost/app-curl:dev-october-fix-uranus-video done
#5 DONE 0.0s
The push refers to repository [registry.localhost/app-curl]
1fd50ac9222f: Preparing
5d64de483bf5: Preparing
1fd50ac9222f: Mounted from base-debian-bookworm
5d64de483bf5: Mounted from base-debian-bookworm
dev-october-fix-uranus-video: digest: sha256:08206d4a2808d58906be345c37f30476cd1e89a7f51c122bf1e98e9c70db7b25 size: 737
67 changes: 67 additions & 0 deletions client/fixtures/report-data/dev/data/app-curl/goss.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "goss",
"errors": "0",
"tests": "8",
"failures": "2",
"skipped": "5",
"time": "0.000",
"timestamp": "2024-06-22T18:56:30Z",
"testcases": [
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "User debiane exists",
"time": "0.000",
"failure": "User: debiane: exists: doesn't match, expect: [true] found: [false]"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "User debiane uid",
"time": "0.000",
"system_out": "User: debiane: uid: skipped"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "User debiane gid",
"time": "0.000",
"system_out": "User: debiane: gid: skipped"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "User debiane home",
"time": "0.000",
"system_out": "User: debiane: home: skipped"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "User debiane groups",
"time": "0.000",
"system_out": "User: debiane: groups: skipped"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "User debiane shell",
"time": "0.000",
"system_out": "User: debiane: shell: skipped"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "Group debian exists",
"time": "0.000",
"system_out": "Group: debian: exists: matches expectation: [true]"
},
{
"class_name": "goss-app-curl",
"file": "docker/app/curl",
"name": "Group debian gid",
"time": "0.000",
"failure": "Group: debian: gid: doesn't match, expect: [1666] found: [1664]"
}
]
}
Loading