revamp stuff / ci
This commit is contained in:
parent
c9a4ce44a5
commit
2d51ab4b76
66
.github/workflows/build.yml
vendored
Normal file
66
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install npm modules
|
||||
run: |
|
||||
cd public && npm ci && npm run jshint && npm run bundle
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v4.1.0
|
||||
with:
|
||||
go-version: "1.21"
|
||||
|
||||
- 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: Tests
|
||||
run: |
|
||||
go test ./...
|
||||
|
||||
- name: Log in to the Container registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# step for tags (v*)
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
if: success() && startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
version: latest
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# step for main/latest (docker only)
|
||||
- name: Build and push latest docker image
|
||||
if: success() && github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
go build -ldflags="-s -w -extldflags=-static"
|
||||
docker build . -t ghcr.io/buckaroobanzay/minetest-web:latest
|
||||
docker push ghcr.io/buckaroobanzay/minetest-web:latest
|
31
.github/workflows/test.yml
vendored
Normal file
31
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- name: Install npm modules
|
||||
run: |
|
||||
cd public && npm ci && npm run jshint && npm run bundle
|
||||
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: 1.21.x
|
||||
|
||||
- name: Test
|
||||
run: |
|
||||
go test ./... -coverprofile=profile.cov
|
||||
|
||||
- uses: shogo82148/actions-goveralls@v1.8.0
|
||||
with:
|
||||
path-to-profile: profile.cov
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
minetest-web
|
21
.goreleaser.yaml
Normal file
21
.goreleaser.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=1
|
||||
targets:
|
||||
- linux_amd64
|
||||
ldflags:
|
||||
- -s -w -extldflags=-static
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
||||
dockers:
|
||||
- image_templates:
|
||||
- "ghcr.io/buckaroobanzay/minetest-web:{{ .Version }}"
|
||||
- "ghcr.io/buckaroobanzay/minetest-web:latest"
|
||||
dockerfile: Dockerfile
|
4
Dockerfile
Normal file
4
Dockerfile
Normal file
@ -0,0 +1,4 @@
|
||||
FROM alpine:3.18.3
|
||||
COPY minetest-web /bin/minetest-web
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["/bin/minetest-web"]
|
@ -1,9 +0,0 @@
|
||||
<html style="height: 100%;">
|
||||
<head>
|
||||
</head>
|
||||
<body style="height: 100%; margin: 0px;">
|
||||
<canvas id="canvas" style="width: 100%; height: 100%;"></canvas>
|
||||
<script src="bootstrap.js"></script>
|
||||
<script src="wasm/minetest.js"></script>
|
||||
</body>
|
||||
</html>
|
12
main.go
12
main.go
@ -1,13 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"minetest-web/public"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
fs := http.FileServer(http.FS(os.DirFS(".")))
|
||||
var fs http.Handler
|
||||
if os.Getenv("WEBDEV") == "true" {
|
||||
// live mode
|
||||
fs = http.FileServer(http.FS(os.DirFS("public")))
|
||||
} else {
|
||||
// embedded mode
|
||||
fs = http.FileServer(http.FS(public.Webapp))
|
||||
}
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Cross-Origin-Embedder-Policy", "require-corp")
|
||||
w.Header().Set("Cross-Origin-Opener-Policy", "same-origin")
|
||||
@ -16,6 +25,7 @@ func main() {
|
||||
|
||||
http.HandleFunc("/proxy", HandleProxy)
|
||||
|
||||
fmt.Println("Listening on port 8080")
|
||||
err := http.ListenAndServe(":8080", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
1
public/.gitignore
vendored
Normal file
1
public/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
14
public/embed.go
Normal file
14
public/embed.go
Normal file
@ -0,0 +1,14 @@
|
||||
package public
|
||||
|
||||
import (
|
||||
"embed"
|
||||
)
|
||||
|
||||
//go:embed js/*
|
||||
//go:embed wasm/*
|
||||
//go:embed *html
|
||||
//go:embed node_modules/vue/dist/vue.global.js
|
||||
//go:embed node_modules/@fortawesome/fontawesome-free/css/all.min.css
|
||||
//go:embed node_modules/@fortawesome/fontawesome-free/webfonts/*
|
||||
//go:embed node_modules/bootswatch/dist/cyborg/bootstrap.min.css
|
||||
var Webapp embed.FS
|
12
public/index.html
Normal file
12
public/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<html style="height: 100%;">
|
||||
<head>
|
||||
<link rel="stylesheet" href="node_modules/@fortawesome/fontawesome-free/css/all.min.css"/>
|
||||
<link rel="stylesheet" href="node_modules/bootswatch/dist/cyborg/bootstrap.min.css"/>
|
||||
</head>
|
||||
<body style="height: 100%; margin: 0px;">
|
||||
<canvas id="canvas" style="width: 100%; height: 100%;"></canvas>
|
||||
<script src="node_modules/vue/dist/vue.global.js"></script>
|
||||
<script src="js/bundle.js" onerror="import('./js/main.js')"></script>
|
||||
<script src="wasm/minetest.js"></script>
|
||||
</body>
|
||||
</html>
|
2
public/js/.gitignore
vendored
Normal file
2
public/js/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
bundle.js
|
||||
bundle.js.map
|
1
public/js/.jshintignore
Normal file
1
public/js/.jshintignore
Normal file
@ -0,0 +1 @@
|
||||
bundle.js
|
10
public/js/.jshintrc
Normal file
10
public/js/.jshintrc
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"esversion": 6,
|
||||
"browser": true,
|
||||
"globals": {
|
||||
"Vue": true,
|
||||
"console": true
|
||||
}
|
||||
}
|
8
bootstrap.js → public/js/bootstrap.js
vendored
8
bootstrap.js → public/js/bootstrap.js
vendored
@ -1,3 +1,5 @@
|
||||
/* globals _malloc, cwrap, HEAPU32, HEAPU8, allocateUTF8 */
|
||||
|
||||
function makeArgv(args) {
|
||||
// Assuming 4-byte pointers
|
||||
const argv = _malloc((args.length + 1) * 4);
|
||||
@ -35,7 +37,7 @@ function addPack(name) {
|
||||
});
|
||||
}
|
||||
|
||||
function emloop_ready() {
|
||||
window.emloop_ready = function() {
|
||||
emloop_pause = cwrap("emloop_pause", null, []);
|
||||
emloop_unpause = cwrap("emloop_unpause", null, []);
|
||||
emloop_init_sound = cwrap("emloop_init_sound", null, []);
|
||||
@ -63,8 +65,8 @@ function emloop_ready() {
|
||||
irrlicht_force_pointerlock();
|
||||
emloop_request_animation_frame();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var Module = {
|
||||
window.Module = {
|
||||
canvas: canvas_el
|
||||
};
|
1
public/js/main.js
Normal file
1
public/js/main.js
Normal file
@ -0,0 +1 @@
|
||||
console.log("start");
|
1011
public/package-lock.json
generated
Normal file
1011
public/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
21
public/package.json
Normal file
21
public/package.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "public",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "bootstrap.js",
|
||||
"scripts": {
|
||||
"jshint": "jshint js/",
|
||||
"bundle": "rollup -c rollup.config.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"jshint": "^2.13.6",
|
||||
"rollup": "^3.29.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fortawesome/fontawesome-free": "^6.4.2",
|
||||
"bootswatch": "^5.3.2",
|
||||
"vue": "^3.3.4"
|
||||
}
|
||||
}
|
10
public/rollup.config.js
Normal file
10
public/rollup.config.js
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
module.exports = [{
|
||||
input: 'js/main.js',
|
||||
output: {
|
||||
file :'js/bundle.js',
|
||||
format: 'iife',
|
||||
sourcemap: true,
|
||||
compact: true
|
||||
}
|
||||
}];
|
Loading…
x
Reference in New Issue
Block a user