Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch to WASM modules #2

Merged
merged 1 commit into from
Oct 22, 2023
Merged
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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
tags:
- '*'

name: release
jobs:
release:

runs-on: ubuntu-latest
env:
GO_VERSION: "1.21"

steps:
- name: Install Go
if: success()
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout code
uses: actions/checkout@v4

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40 changes: 40 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
on:
push:
branches:
- main
pull_request:

name: run tests
jobs:
test:

runs-on: ubuntu-latest
env:
GOOS: js
GOARCH: wasm
GO_VERSION: "1.21"
GOLANGCI_LINT_VERSION: v1.55.0

steps:
- name: Install Go
if: success()
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout code
uses: actions/checkout@v4

- name: Cache Go modules
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: Run linter
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
skip-pkg-cache: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist
33 changes: 22 additions & 11 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,51 @@
run:
tests: false
timeout: 5m
deadline: 5m

linters-settings:
cyclop:
max-complexity: 20
skip-tests: true
funlen:
lines: 80
gofumpt:
extra-rules: true

linters:
enable-all: true
disable:
- interfacebloat
- sqlclosecheck # not relevant (SQL)
- rowserrcheck # not relevant (SQL)
- execinquery # not relevant (SQL)
- interfacer # deprecated
- scopelint # deprecated
- maligned # deprecated
- golint # deprecated
- durationcheck
- deadcode # deprecated
- exhaustivestruct # deprecated
- ifshort # deprecated
- nosnakecase # deprecated
- structcheck # deprecated
- varcheck # deprecated
- cyclop # duplicate of gocyclo
- depguard
- exhaustive
- exhaustivestruct
- exhaustruct
- forcetypeassert
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- gocyclo
- goerr113
- gomnd
- ireturn
- nestif
- nlreturn
- nilerr
- noctx
- nonamedreturns
- tagliatelle
- varnamelen
- wrapcheck
- wsl

issues:
exclude-use-default: false
exclude:
- 'ST1000: at least one file in a package should have a package comment'
- 'ST1000: at least one file in a package should have a package comment'
- 'package-comments: should have a package comment'
35 changes: 35 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
project_name: clock
dist: dist

gomod:
proxy: true

builds:
- main: ./
binary: clock
goos:
- js
goarch:
- wasm
env:
- CGO_ENABLED=0

archives:
- format: binary
name_template: '{{ .Binary }}'

changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^doc:'
- '^tests:'
- '^test:'
- '^chore:'

checksum:
name_template: '{{ .ProjectName }}_checksums.txt'

snapshot:
name_template: "{{ .Tag }}"
36 changes: 36 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
GOOS=js
GOARCH=wasm

export GOOS
export GOARCH

# Format all files
fmt:
@echo "==> Formatting source"
@gofmt -s -w $(shell find . -type f -name '*.go' -not -path "./vendor/*")
@echo "==> Done"
.PHONY: fmt

# Tidy the go.mod file
tidy:
@echo "==> Cleaning go.mod"
@go mod tidy
@echo "==> Done"
.PHONY: tidy

# Lint the project
lint:
@echo "==> Linting Go files"
@golangci-lint run ./...
.PHONY: lint

# Run all tests
test:
@go test -cover ./...
.PHONY: test

# Build the commands
build:
@goreleaser release --clean --snapshot
.PHONY: build

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ to under modules in your configuration.
```yaml
modules:
- name: simple-clock
path: github.com/glasslabs/clock
url: https://github.com/glasslabs/clock/releases/download/v1.0.0/clock.wasm
position: top:right
config:
timeFormat: 15:04
Expand Down
114 changes: 0 additions & 114 deletions clock.go

This file was deleted.

9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module github.com/glasslabs/clock

go 1.17
go 1.21.3

require github.com/glasslabs/looking-glass v0.2.0
require github.com/glasslabs/client-go v0.1.0

require (
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/js/dom/v2 v2.0.0-20230808055721-96db8f4d5e3b // indirect
)
Loading
Loading