Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Update to latest wasi-go
Browse files Browse the repository at this point in the history
  • Loading branch information
Pryz committed May 8, 2023
1 parent d70f714 commit 14a2f3b
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 7 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: go-lint
on:
push:
tags:
- v*
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.number || github.ref }}
cancel-in-progress: true

env:
# renovate: datasource=go depName=github.com/golangci/golangci-lint
GOLANGCI_LINT_VERSION: v1.52.2

jobs:
lint:
name: Go Lint
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: .go-version
check-latest: true
cache: true

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: ${{ env.GOLANGCI_LINT_VERSION }}
args: --timeout 5m
37 changes: 37 additions & 0 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: go-release

on:
push:
# run only against tags
tags:
- 'v*'

permissions:
contents: write
# packages: write
# issues: write

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-go@v4
with:
go-version-file: .go-version
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- uses: goreleaser/goreleaser-action@v4
with:
# either 'goreleaser' (default) or 'goreleaser-pro':
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
# distribution:
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
21 changes: 21 additions & 0 deletions .github/workflows/go-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: go-test

on:
push:
branches: [ "main" ]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version-file: .go-version
check-latest: true

- name: Test
run: go test -v ./...
38 changes: 38 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
run:
deadline: 7m
timeout: 5m
go: '1.20'

linters:
enable:
- depguard
- godot
- gofumpt
- goimports
- revive
- whitespace

issues:
exclude-rules:
- path: _test.go
linters:
- errcheck

linters-settings:
depguard:
list-type: blacklist
include-go-root: true
packages-with-error-message: []
errcheck:
goimports:
local-prefixes: github.com/stealthrocket/wzprof
gofumpt:
extra-rules: true
misspell:
locale: US
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unexported-return
- name: unexported-return
severity: warning
disabled: true
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM golang:1.20-alpine as build

RUN apk update && apk add make git gcc libc-dev curl

WORKDIR /go/src/github.com/stealthrocket/timecraft
COPY . .

ARG version
ARG tags
ARG gocache

RUN go build -o timecraft

# The last layer of the build, which determines what the final docker image
# will contain.
FROM alpine

RUN apk update && apk add ca-certificates curl bind-tools tree

ENV TIMECRAFT_BIND=:8080

EXPOSE 8080/tcp

COPY --from=build /go/src/github.com/stealthrocket/timecraft/timecraft /usr/bin/timecraft

ENTRYPOINT ["timecraft"]
8 changes: 4 additions & 4 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"time"

"github.com/spf13/cobra"
"github.com/stealthrocket/wasi"
"github.com/stealthrocket/wasi/imports/wasi_snapshot_preview1"
"github.com/stealthrocket/wasi/wasiunix"
"github.com/stealthrocket/wasi-go"
"github.com/stealthrocket/wasi-go/imports/wasi_snapshot_preview1"
"github.com/stealthrocket/wasi-go/systems/unix"
"github.com/stealthrocket/wazergo"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/sys"
Expand Down Expand Up @@ -47,7 +47,7 @@ func run(ctx context.Context, args []string) error {
environ = append(environ, "PWD="+wd)
}

provider := &wasiunix.Provider{
provider := &unix.System{
Args: append([]string{wasmName}, args[1:]...),
Environ: environ,
Realtime: realtime,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/klauspost/compress v1.16.5
github.com/spf13/cobra v1.7.0
github.com/stealthrocket/wasi v0.0.0-20230504000138-9d2008307ac8
github.com/stealthrocket/wasi-go v0.0.0-20230508014825-d291ccc8185a
github.com/stealthrocket/wazergo v0.17.1
github.com/tetratelabs/wazero v1.1.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stealthrocket/wasi v0.0.0-20230504000138-9d2008307ac8 h1:WJVwrOL+OsVij6NM5vTb7iU5KoE3YgbPdD5rh4PfIm4=
github.com/stealthrocket/wasi v0.0.0-20230504000138-9d2008307ac8/go.mod h1:6GDKyiPuzLz3LJ91aGvrw9qca7XXAANIyiGMGRnujHo=
github.com/stealthrocket/wasi-go v0.0.0-20230508014825-d291ccc8185a h1:qf504FlX3/eGQgjDfCB9/uZtH/3i7w7lpx3B9bDWMfY=
github.com/stealthrocket/wasi-go v0.0.0-20230508014825-d291ccc8185a/go.mod h1:cSfmIlZZjwC6SoxMEsWVEcC2eSUQhfZQOdB99rKKAr8=
github.com/stealthrocket/wazergo v0.17.1 h1:lXx4/Lg1A+9ATZWYI0J2E4oWfihhOLxWfnAT2Wy8iKQ=
github.com/stealthrocket/wazergo v0.17.1/go.mod h1:riI0hxw4ndZA5e6z7PesHg2BtTftcZaMxRcoiGGipTs=
github.com/tetratelabs/wazero v1.1.0 h1:EByoAhC+QcYpwSZJSs/aV0uokxPwBgKxfiokSUwAknQ=
Expand Down

0 comments on commit 14a2f3b

Please sign in to comment.