Skip to content

Commit

Permalink
Merge pull request #1 from lucasmenendez/dev
Browse files Browse the repository at this point in the history
release new version web assembly based
  • Loading branch information
lucasmenendez authored Oct 22, 2023
2 parents 33a0939 + a4034a2 commit d1b8382
Show file tree
Hide file tree
Showing 64 changed files with 2,606 additions and 30,169 deletions.
55 changes: 55 additions & 0 deletions .github/parse-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const readline = require("readline");

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false,
});

const summary = { fail: [], pass: [], skip: [] };

rl.on("line", (line) => {
const output = JSON.parse(line);
if (
output.Action === "pass" ||
output.Action === "skip" ||
output.Action === "fail"
) {
if (output.Test) {
summary[output.Action].push(output);
}
}
});

function totalTime(entries) {
return entries.reduce((total, l) => total + l.Elapsed, 0);
}

rl.on("close", () => {
console.log("## 📋 Tests executed");
console.log("| | Number of Tests | Total Time |");
console.log("|--|--|--|");
console.log(
"| ✅ Passed | %d | %fs |",
summary.pass.length,
totalTime(summary.pass)
);
console.log(
"| ❌ Failed | %d | %fs |",
summary.fail.length,
totalTime(summary.fail)
);
console.log(
"| 🔜 Skipped | %d | %fs |",
summary.skip.length,
totalTime(summary.skip)
);

if (summary.fail.length > 0) {
console.log("\n## Failures\n");
}

summary.fail.forEach((test) => {
console.log("* %s (%s) %fs", test.Test, test.Package, test.Elapsed);
});
});
20 changes: 0 additions & 20 deletions .github/workflows/gh-pages.yml

This file was deleted.

103 changes: 103 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Release new version

on:
push:
tags:
- '*'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m --verbose
skip-cache: false
skip-pkg-cache: false
skip-build-cache: false
only-new-issues: true
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.21.x
cache: true
- name: run test
run: |
go test -v --race -timeout 15m -coverprofile=./cover.out -json ./... > tests.log
- name: convert coverage to html
run: go tool cover -html=cover.out -o cover.html
- name: print test report
run: |
set -o pipefail && cat tests.log | node .github/parse-tests.js >> $GITHUB_STEP_SUMMARY
echo $GITHUB_STEP_SUMMARY
- name: print coverage result
run: |
go tool cover -func=cover.out > ./cover.txt
echo "<details><summary>📏 Tests coverage</summary>" >> $GITHUB_STEP_SUMMARY
echo -e "\n\`\`\`" >> $GITHUB_STEP_SUMMARY
cat ./cover.txt >> $GITHUB_STEP_SUMMARY
echo -e "\`\`\`\n</details>" >> $GITHUB_STEP_SUMMARY
- name: store code coverage artifact
uses: actions/upload-artifact@v3
with:
name: report
path: |
tests.log
cover.txt
cover.out
cover.html
publish:
runs-on: ubuntu-latest
env:
GOOS: js
GOARCH: wasm
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.21.x
cache: true
- name: Build wasm
run: |
go build -o ./web/mykeys.wasm ./cmd/webassembly/main.go
- name: Copy go wasm js engine
run: |
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./web
- name: Generate checksum
uses: jmgilman/actions-generate-checksum@v1
with:
output: sha256_checksums.txt
patterns: |
web/mykeys.wasm
web/wasm_exec.js
- name: Upload assets
uses: softprops/action-gh-release@v1
id: upload-release-asset
with:
files: |
sha256_checksums.txt
web/mykeys.wasm
web/wasm_exec.js
- name: Print assets urls
run: |
echo "${{ fromJSON(steps.upload-release-asset.outputs.assets)[0].browser_download_url }}"
echo "${{ fromJSON(steps.upload-release-asset.outputs.assets)[1].browser_download_url }}"
echo "${{ fromJSON(steps.upload-release-asset.outputs.assets)[2].browser_download_url }}"
- name: Deploy to github pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: web

55 changes: 55 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint and test
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Go
uses: actions/setup-go@v3
with:
go-version: 1.21.x
cache: true
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
args: --timeout 5m --verbose
skip-cache: false
skip-pkg-cache: false
skip-build-cache: false
only-new-issues: true
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.21.x
cache: true
- name: run test
run: |
go test -v --race -timeout 15m -coverprofile=./cover.out -json ./... > tests.log
- name: convert coverage to html
run: go tool cover -html=cover.out -o cover.html
- name: print test report
run: |
set -o pipefail && cat tests.log | node .github/parse-tests.js >> $GITHUB_STEP_SUMMARY
echo $GITHUB_STEP_SUMMARY
- name: print coverage result
run: |
go tool cover -func=cover.out > ./cover.txt
echo "<details><summary>📏 Tests coverage</summary>" >> $GITHUB_STEP_SUMMARY
echo -e "\n\`\`\`" >> $GITHUB_STEP_SUMMARY
cat ./cover.txt >> $GITHUB_STEP_SUMMARY
echo -e "\`\`\`\n</details>" >> $GITHUB_STEP_SUMMARY
- name: store code coverage artifact
uses: actions/upload-artifact@v3
with:
name: report
path: |
tests.log
cover.txt
cover.out
cover.html
21 changes: 0 additions & 21 deletions .gitignore

This file was deleted.

Loading

0 comments on commit d1b8382

Please sign in to comment.