Skip to content

Commit 864813d

Browse files
v2: removing database (#1)
New features: * Full refactor * Stateless app id and tokens (database is not required anymore) * Codebase improved * More tests Changes: * dependencies updated * workflow for testing on github actions * include hedged nonce during sign generation * new email package with tests and new templates definitions which support plain and html content * update main with new changes and new workflow step to show the test coverage in a report * new notifications and mail templates, including login mail template * new token package with new structs to better data management, including expirations, secrets and tokens * full api implementation with basic features, includes requests, responses, errors and initial tests * new LICENSE and README * new api/io package with more tests
1 parent 332ce6e commit 864813d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+5984
-2601
lines changed

.github/parse-coverage-report.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const readline = require("readline");
2+
3+
const rl = readline.createInterface({
4+
input: process.stdin,
5+
output: process.stdout,
6+
terminal: false,
7+
});
8+
9+
const summary = { fail: [], pass: [], skip: [] };
10+
11+
rl.on("line", (line) => {
12+
const output = JSON.parse(line);
13+
if (
14+
output.Action === "pass" ||
15+
output.Action === "skip" ||
16+
output.Action === "fail"
17+
) {
18+
if (output.Test) {
19+
summary[output.Action].push(output);
20+
}
21+
}
22+
});
23+
24+
function totalTime(entries) {
25+
return entries.reduce((total, l) => total + l.Elapsed, 0);
26+
}
27+
28+
rl.on("close", () => {
29+
console.log("## 📋 Tests executed");
30+
console.log("| | Number of Tests | Total Time |");
31+
console.log("|--|--|--|");
32+
console.log(
33+
"| ✅ Passed | %d | %fs |",
34+
summary.pass.length,
35+
totalTime(summary.pass)
36+
);
37+
console.log(
38+
"| ❌ Failed | %d | %fs |",
39+
summary.fail.length,
40+
totalTime(summary.fail)
41+
);
42+
console.log(
43+
"| 🔜 Skipped | %d | %fs |",
44+
summary.skip.length,
45+
totalTime(summary.skip)
46+
);
47+
48+
if (summary.fail.length > 0) {
49+
console.log("\n## Failures\n");
50+
}
51+
52+
summary.fail.forEach((test) => {
53+
console.log("* %s (%s) %fs", test.Test, test.Package, test.Elapsed);
54+
});
55+
});

.github/workflows/main.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
job_go_checks:
11+
runs-on: ubuntu-latest
12+
defaults:
13+
run:
14+
shell: bash
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 1
20+
- name: Set up Go environment
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version: "1.24"
24+
- name: Tidy go module
25+
run: |
26+
go mod tidy
27+
if [[ $(git status --porcelain) ]]; then
28+
git diff
29+
echo
30+
echo "go mod tidy made these changes, please run 'go mod tidy' and include those changes in a commit"
31+
exit 1
32+
fi
33+
- name: Run gofumpt
34+
run: diff -u <(echo -n) <(go run mvdan.cc/gofumpt@@latest -d .)
35+
- name: Run go vet
36+
run: go vet ./...
37+
38+
job_go_test:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
with:
44+
fetch-depth: 2
45+
- name: Set up Go environment
46+
uses: actions/setup-go@v5
47+
with:
48+
go-version: "1.24"
49+
- name: Run Go test -race
50+
run: go test ./... -v -race -timeout=1h
51+
- name: Rerun Go test to generate coverage report
52+
run: |
53+
go test -v -timeout 15m -coverprofile=./cover.out -json ./... > tests.log
54+
- name: Convert report to html
55+
run: go tool cover -html=cover.out -o cover.html
56+
- name: Print coverage report
57+
run: |
58+
set -o pipefail && cat tests.log | node .github/parse-coverage-report.js >> $GITHUB_STEP_SUMMARY
59+
echo $GITHUB_STEP_SUMMARY
60+
- name: Print coverage report
61+
run: |
62+
go tool cover -func=cover.out > ./cover.txt
63+
echo "<details><summary>📏 Tests coverage</summary>" >> $GITHUB_STEP_SUMMARY
64+
echo -e "\n\`\`\`" >> $GITHUB_STEP_SUMMARY
65+
cat ./cover.txt >> $GITHUB_STEP_SUMMARY
66+
echo -e "\`\`\`\n</details>" >> $GITHUB_STEP_SUMMARY
67+
- name: Store coverage report
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: report
71+
path: |
72+
tests.log
73+
cover.txt
74+
cover.out
75+
cover.html

0 commit comments

Comments
 (0)