Skip to content

Commit

Permalink
initial public commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jellevandenhooff committed Nov 22, 2024
0 parents commit 37a4fea
Show file tree
Hide file tree
Showing 202 changed files with 39,324 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .ci/crossarch-tests/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# XXX: parametrize somehow?
FROM golang:1.23

ENV GOCACHE=/cache/GOCACHE GOMODCACHE=/cache/GOMODCACHE GOSIMCACHE=/cache/GOSIMCACHE

WORKDIR /go/src/
COPY . /go/src/

# clean up .gosim/ if copied
RUN rm -rf .gosim/

# run with limited concurrency to limit memory usage
CMD ./test.sh --concurrency 1
21 changes: 21 additions & 0 deletions .ci/crossarch-tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
services:
test-linux-arm64:
platform: linux/amd64
build:
context: ../..
dockerfile: ./.ci/crossarch-tests/Dockerfile.test
volumes:
- cache:/cache

test-linux-amd64:
platform: linux/amd64
build:
context: ../..
dockerfile: ./.ci/crossarch-tests/Dockerfile.test
volumes:
- cache:/cache

volumes:
cache:


5 changes: 5 additions & 0 deletions .ci/crossarch-tests/test-amd64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
cd "${0%/*}"
set -e

docker compose -f ./docker-compose.yml run --build --rm test-linux-amd64
5 changes: 5 additions & 0 deletions .ci/crossarch-tests/test-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
cd "${0%/*}"
set -e

docker compose -f ./docker-compose.yml run --build --rm test-linux-arm64
28 changes: 28 additions & 0 deletions .ci/gofmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# gofmt checks that code is formatted with gofumpt and sorted inputs

gofiles=$(find . -name "*.go" -and -not -ipath "./gosimout/*" -exec sh -c 'head -1 {} | grep -q "DO NOT EDIT." || echo {}' \;)
goimports="go run golang.org/x/tools/cmd/goimports -local=github.com/jellevandenhooff/gosim -format-only"
gofumpt="go run mvdan.cc/gofumpt"

if [[ $1 == "check" ]]; then
echo goimports
output=$($goimports -l $gofiles)
if [[ -n "$output" ]]; then
echo $output
exit 1
fi
echo gofumpt
output=$($gofumpt -l $gofiles)
if [[ -n "$output" ]]; then
echo $output
exit 1
fi
elif [[ $1 == "fix" ]]; then
echo goimports
$goimports -w $gofiles
echo gofumpt
$gofumpt -w $gofiles
else
echo "usage $0 [check|fix]"
fi
3 changes: 3 additions & 0 deletions .ci/gosim
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
# gosim is shorthand for running cmd/gosim:
go run github.com/jellevandenhooff/gosim/cmd/gosim "$@"
27 changes: 27 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

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

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

# run tests with -trimpath to hopefully share cache between gosim
# invocations in different folders
- name: Test
run: GOFLAGS=-trimpath ./test.sh --concurrency 1
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.gosim/
next.txt
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Connect to dlv-dap server on localhost:2345",
"type": "go",
"request": "attach",
"mode": "remote",
"remotePath": "${workspaceFolder}",
"port": 2345,
"host": "127.0.0.1",
"debugAdapter": "dlv-dap",
"stopOnEntry": true,
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"gopls": {
"build.env": {
"GOOS": "linux",
},
"formatting.local": "github.com/jellevandenhooff/gosim",
"formatting.gofumpt": true
},
"go.buildFlags": [
"-tags=sim,linkname",
"-ldflags=-checklinkname=0",
],
}
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2024 Jelle van den Hooff

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 37a4fea

Please sign in to comment.