feat: Add ci and wasm pages

This commit is contained in:
uttarayan21
2024-06-19 03:09:12 +05:30
parent cd5ea497fb
commit 89c3c5b9de
3 changed files with 90 additions and 2 deletions
+34
View File
@@ -0,0 +1,34 @@
name: CI
on:
push:
pull_request:
jobs:
check:
runs-on: ubuntu-22.04
permissions:
contents: "read"
id-token: "write"
pages: "write"
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- name: Run `nix build wasm`
run: nix build .#tadventure-wasm
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: result/dist
- name: Deploy to gh-pages
id: deployment
uses: actions/deploy-pages@v4
+29
View File
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tadventure</title>
<style>
html,
body,
canvas {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
background: black;
z-index: 0;
}
</style>
</head>
<body>
<canvas id="glcanvas" tabindex='1'></canvas>
<script src="https://not-fl3.github.io/miniquad-samples/gl.js"></script>
<script>load("tadventure.wasm");</script> <!-- Your compiled wasm file -->
</body>
</html>
+27 -2
View File
@@ -40,7 +40,7 @@
# Extra targets if required
};
craneLib = (crane.mkLib pkgs).overrideToolchain stableToolchain;
src = craneLib.cleanCargoSource (craneLib.path ./.);
src = craneLib.path ./.;
commonArgs = {
inherit src;
buildInputs = with pkgs;
@@ -61,7 +61,7 @@
];
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
in {
in rec {
checks = {
tadventure-clippy = craneLib.cargoClippy (commonArgs
// {
@@ -111,10 +111,35 @@
inherit src;
doCheck = false;
cargoExtraArgs = "--target wasm32-unknown-unknown";
installPhase = ''
mkdir -p $out/dist
cp target/wasm32-unknown-unknown/release/tadventure.wasm $out/dist/tadventure.wasm
cp $src/assets/index.html $out/dist/index.html
'';
meta.mainProgram = null;
};
default = tadventure;
};
apps = {
default = let
wasm = pkgs.writeShellApplication {
# Our shell script name is serve
# so it is available at $out/bin/serve
name = "tadventure";
# Caddy is a web server with a convenient CLI interface
runtimeInputs = [pkgs.caddy];
text = ''
# Serve the current directory on port 8090
caddy file-server --listen :8000 --root ${packages.tadventure-wasm}/dist
'';
};
in {
type = "app";
program = "${wasm}/bin/tadventure";
};
};
devShells.default = (craneLib.overrideToolchain stableToolchainWithRustAnalyzer).devShell (commonArgs
// {
buildInputs = [];