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

Update to latest wasi-go #2

Closed
wants to merge 5 commits into from
Closed
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
77 changes: 77 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: build
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:
spellcheck:
name: Spell Check
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v2

- name: Check spelling of Go files
uses: crate-ci/typos@master
with:
files: '*.go'
write_changes: true

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

- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PAT }}
run: git config --global url."https://Pryz:${TOKEN}@github.com".insteadOf "https://github.com"

- 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

test:
name: Go Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Configure git for private modules
env:
TOKEN: ${{ secrets.PAT }}
run: git config --global url."https://Pryz:${TOKEN}@github.com".insteadOf "https://github.com"

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

- name: Test
run: go test -v ./...
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.20.4
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 @@
"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"

Check failure on line 13 in cmd/run.go

View workflow job for this annotation

GitHub Actions / Go Test

github.com/stealthrocket/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/c4640a01f94395c95771de09976cf4476478c100a7acfdc54671a83ec05f4a9d: exit status 128:
"github.com/stealthrocket/wasi-go/imports/wasi_snapshot_preview1"

Check failure on line 14 in cmd/run.go

View workflow job for this annotation

GitHub Actions / Go Test

github.com/stealthrocket/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/c4640a01f94395c95771de09976cf4476478c100a7acfdc54671a83ec05f4a9d: exit status 128:
"github.com/stealthrocket/wasi-go/systems/unix"

Check failure on line 15 in cmd/run.go

View workflow job for this annotation

GitHub Actions / Go Test

github.com/stealthrocket/[email protected]: invalid version: git ls-remote -q origin in /home/runner/go/pkg/mod/cache/vcs/c4640a01f94395c95771de09976cf4476478c100a7acfdc54671a83ec05f4a9d: exit status 128:
"github.com/stealthrocket/wazergo"
"github.com/tetratelabs/wazero"
"github.com/tetratelabs/wazero/sys"
Expand Down Expand Up @@ -47,7 +47,7 @@
environ = append(environ, "PWD="+wd)
}

provider := &wasiunix.Provider{
provider := &unix.System{
Args: append([]string{wasmName}, args[1:]...),
Environ: environ,
Realtime: realtime,
Expand Down Expand Up @@ -80,9 +80,9 @@
return fmt.Errorf("opening root directory: %w", err)
}

provider.Preopen(stdin, "/dev/stdin", wasi.FDStat{

Check failure on line 83 in cmd/run.go

View workflow job for this annotation

GitHub Actions / Go Lint

undefined: wasi (typecheck)
FileType: wasi.CharacterDeviceType,

Check failure on line 84 in cmd/run.go

View workflow job for this annotation

GitHub Actions / Go Lint

undefined: wasi (typecheck)
RightsBase: wasi.AllRights,

Check failure on line 85 in cmd/run.go

View workflow job for this annotation

GitHub Actions / Go Lint

undefined: wasi (typecheck)
})

provider.Preopen(stdout, "/dev/stdout", wasi.FDStat{
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
Loading