Skip to content

Commit

Permalink
Refactor build workflow to include WASM package upload step and updat…
Browse files Browse the repository at this point in the history
…e interceptor artifact path
  • Loading branch information
ternakkode committed Sep 29, 2024
1 parent b69c817 commit 5f74e91
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 79 deletions.
23 changes: 0 additions & 23 deletions .github/workflows/baseline.yml

This file was deleted.

26 changes: 0 additions & 26 deletions .github/workflows/publish.yml

This file was deleted.

27 changes: 23 additions & 4 deletions .github/workflows/build.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build WASM Package
name: Release
on:
release:
types:
Expand Down Expand Up @@ -41,7 +41,7 @@ jobs:
name: interceptor
path: bin/
s3:
name: Upload WASM Package to CDN
name: Upload WASM File to CDN
needs: build
runs-on: ubuntu-latest
steps:
Expand All @@ -57,5 +57,24 @@ jobs:
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Upload WASM to S3
run: aws s3 cp bin/interceptor.wasm.br s3://layer8-interceptor/${{ github.sha }}.wasm.br --content-encoding br --content-type application/wasm

run: aws s3 cp bin/interceptor.wasm.br s3://layer8-interceptor/${{ github.sha }}.wasm.br --content-encoding br --content-type application/wasm --acl public-read
publish:
name: Publish Node Package
needs: s3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: https://npm.pkg.github.com/
- name: Install Utilities
run: apt-get install jq moreutils
- name: Setup WASM Config
run: jq '.wasm_url = "${{vars.CLOUDFRONT_CDN_DOMAIN}}/${{ github.sha }}"' config.json | sponge config.json
- name: Install Dependencies
run: npm install
- name: Publish Package
run: npm publish --access public

3 changes: 3 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"wasm_url": "https://d2063k79vh7a9d.cloudfront.net/b69c8172ef38807dec39fcfd7984b95a1b509c4f.wasm.br"
}
27 changes: 8 additions & 19 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
// IMPORTS
import wasmBin from "./dist/interceptor.json";
import "./dist/wasm_exec.js";
import './wasm_exec.js';
import { wasm_url} from './config.json'

// GLOBALS
let l8Ready = false;
let callbackObjectArray = [];
let layer8;

// UTILITY FUNCS
const decode = (encoded) => {
var str = atob(encoded);
var bytes = new Uint8Array(str.length);
for (var i = 0; i < str.length; i++) {
bytes[i] = str.charCodeAt(i);
}
return bytes.buffer;
};

function illGetBackToYou(_func_name, _resolve, _reject, _args) {
callbackObjectArray.push({
func_name: _func_name,
Expand All @@ -41,15 +29,16 @@ function triggerCallbacks() {
});
}

// MODULE LOAD & INITIAZLIZE
const go = new window.Go();
const importObject = go.importObject;
WebAssembly.instantiate(decode(wasmBin), importObject).then((result) => {

const go = new Go();
WebAssembly.instantiateStreaming(fetch(wasm_url), go.importObject).
then((result) => {
go.run(result.instance);
l8Ready = true;
layer8 = window.layer8;
triggerCallbacks();
});
});


// EXPORTS
export default {
Expand Down
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "layer8_interceptor",
"version": "0.0.18",
"name": "layer8interceptor",
"version": "0.1.0",
"type": "module",
"description": "This package allows Layer8 clients to connect to the remote Layer8 Server. It povides the 1) stock WASM glue code 2) binary of the Interceptor, and 3) the index.js necessary to run it. ",
"main": "index.js",
"types": "index.d.ts",
Expand All @@ -26,9 +27,11 @@
},
"homepage": "https://github.com/globe-and-citizen/layer8-interceptor#readme",
"files": [
"./dist/interceptor.json",
"./dist/wasm_exec.js",
"index.js",
"wasm_exec.js",
"index.d.ts",
"index.js"
]
}
"config.json"
],
"dependencies": {
}
}

0 comments on commit 5f74e91

Please sign in to comment.