Interceptor To Middleware E2E Test #58
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Interceptor To Middleware E2E Test | |
on: | |
workflow_dispatch: | |
inputs: | |
branch: | |
description: 'Branch to run the tests on' | |
required: false | |
default: 'main' | |
type: string | |
push: | |
branches: main | |
jobs: | |
test-imsharer: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Upgrade node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.15.0' | |
- name: Clone layer8 | |
uses: actions/checkout@v4 | |
with: | |
repository: globe-and-citizen/layer8 | |
path: layer8 | |
ref: development | |
- name: Run layer8 server | |
run: | | |
cd layer8 | |
sed -i "s/TEST_CLIENT_BACKEND_URL=localhost:8000/TEST_CLIENT_BACKEND_URL=localhost:6001/g" server/.env.dev | |
sed -i "s/TEST_CLIENT_BACKEND_URI=http:\/\/localhost:8000/TEST_CLIENT_BACKEND_URI=http:\/\/localhost:6001/g" server/.env.dev | |
make setup_and_run & | |
for attempt in {1..30}; do sleep 2; if curl -s http://localhost:5001/ > /dev/null; then break; fi; done | |
- name: Clone middleware | |
uses: actions/checkout@v4 | |
with: | |
repository: globe-and-citizen/layer8-middleware | |
path: layer8-middleware | |
ref: development | |
- name: Build middleware | |
run: | | |
cd layer8-middleware | |
make build | |
mkdir -p ../layer8/sp_mocks/imsharer/backend/dist/dist | |
cp ./index.js ../layer8/sp_mocks/imsharer/backend/dist/middleware.js | |
mv ./dist/middleware.json ../layer8/sp_mocks/imsharer/backend/dist/dist/ | |
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ../layer8/sp_mocks/imsharer/backend/dist/dist/ | |
- name: Clone interceptor | |
uses: actions/checkout@v4 | |
with: | |
repository: globe-and-citizen/layer8-interceptor | |
path: layer8-interceptor | |
ref: development | |
- name: Build interceptor | |
run: | | |
cd layer8-interceptor | |
echo "LAYER8_PROXY_SCHEME=http" > .env | |
echo "LAYER8_PROXY_DOMAIN=localhost" >> .env | |
echo "LAYER8_PROXY_PORT=5001" >> .env | |
make build | |
mkdir -p ../layer8/sp_mocks/imsharer/frontend/src/dist/dist | |
cp ./index.js ../layer8/sp_mocks/imsharer/frontend/src/dist/interceptor.js | |
mv ./dist/interceptor.json ../layer8/sp_mocks/imsharer/frontend/src/dist/dist/ | |
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ../layer8/sp_mocks/imsharer/frontend/src/dist/dist/ | |
- name: Run imsharer backend | |
run: | | |
cd layer8/sp_mocks/imsharer/backend | |
sed -i "s/('layer8_middleware')/('.\/dist\/middleware')/g" index.js | |
npm install | |
node index.js & | |
for attempt in {1..20}; do sleep 2; if curl -s http://localhost:6001/ > /dev/null; then break; fi; done | |
- name: Run imsharer frontend | |
run: | | |
cd layer8/sp_mocks/imsharer/frontend | |
sed -i "s/('layer8_interceptor')/('..\/dist\/interceptor')/g" src/App.vue | |
sed -i "s/('layer8_interceptor')/('..\/..\/dist\/interceptor')/g" src/views/HomeView.vue | |
npm install | |
npm run dev & | |
for attempt in {1..20}; do sleep 2; if curl -s http://localhost:5173/ > /dev/null; then break; fi; done | |
- name: Run cypress tests | |
uses: cypress-io/github-action@v6 | |
with: | |
wait-on: 'http://localhost:5173, http://localhost:6001, http://localhost:5001' | |
spec: cypress/e2e/imsharer/*.cy.js | |
test-wgp: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Upgrade node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.15.0' | |
- name: Clone layer8 | |
uses: actions/checkout@v4 | |
with: | |
repository: globe-and-citizen/layer8 | |
path: layer8 | |
ref: development | |
- name: Run layer8 server | |
run: | | |
cd layer8 | |
sed -i "s/TEST_CLIENT_BACKEND_URL=localhost:8000/TEST_CLIENT_BACKEND_URL=localhost:6002/g" server/.env.dev | |
sed -i "s/TEST_CLIENT_BACKEND_URI=http:\/\/localhost:8000/TEST_CLIENT_BACKEND_URI=http:\/\/localhost:6002/g" server/.env.dev | |
make setup_and_run & | |
for attempt in {1..30}; do sleep 2; if curl -s http://localhost:5001/ > /dev/null; then break; fi; done | |
- name: Clone middleware | |
uses: actions/checkout@v4 | |
with: | |
repository: globe-and-citizen/layer8-middleware | |
path: layer8-middleware | |
ref: development | |
- name: Build middleware | |
run: | | |
cd layer8-middleware | |
make build | |
mkdir -p ../layer8/sp_mocks/imsharer/backend/dist/dist | |
cp ./index.js ../layer8/sp_mocks/imsharer/backend/dist/middleware.js | |
mv ./dist/middleware.json ../layer8/sp_mocks/imsharer/backend/dist/dist/ | |
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ../layer8/sp_mocks/imsharer/backend/dist/dist/ | |
- name: Clone interceptor | |
uses: actions/checkout@v4 | |
with: | |
repository: globe-and-citizen/layer8-interceptor | |
path: layer8-interceptor | |
ref: development | |
- name: Build interceptor | |
run: | | |
cd layer8-interceptor | |
echo "LAYER8_PROXY_SCHEME=http" > .env | |
echo "LAYER8_PROXY_DOMAIN=localhost" >> .env | |
echo "LAYER8_PROXY_PORT=5001" >> .env | |
make build | |
mkdir -p ../layer8/sp_mocks/imsharer/frontend/src/dist/dist | |
cp ./index.js ../layer8/sp_mocks/imsharer/frontend/src/dist/interceptor.js | |
mv ./dist/interceptor.json ../layer8/sp_mocks/imsharer/frontend/src/dist/dist/ | |
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ../layer8/sp_mocks/imsharer/frontend/src/dist/dist/ | |
- name: Run WGP backend | |
run: | | |
cd layer8/sp_mocks/wgp/backend | |
echo "PORT=6002" > .env | |
echo "FRONTEND_URL=http://localhost:5173" >> .env | |
echo "LAYER8_URL=http://localhost:5001" >> .env | |
echo "BACKEND_URL=http://localhost:6002" >> .env | |
sed -i "s/('layer8_middleware')/('.\/dist\/middleware')/g" server.js | |
sed -i "s/\/\/app.use(Layer8);/app.get(\"\/\", (req, res) => {res.json({message: \"Hello there!\"})});/g" server.js | |
npm install | |
node server.js & | |
for attempt in {1..20}; do sleep 2; if curl -s http://localhost:6002/ > /dev/null; then break; fi; done | |
- name: Run WGP frontend | |
run: | | |
cd layer8/sp_mocks/wgp/frontend | |
echo "VITE_BACKEND_URL = http://localhost:6002" > .env | |
echo "VITE_PROXY_URL = http://localhost:5001" >> .env | |
sed -i "s/('layer8_interceptor')/('.\/dist\/interceptor')/g" src/App.vue | |
sed -i "s/('layer8_interceptor')/('..\/dist\/interceptor')/g" src/views/CallBack.vue | |
sed -i "s/('layer8_interceptor')/('..\/dist\/interceptor')/g" src/views/Home.vue | |
sed -i "s/('layer8_interceptor')/('..\/dist\/interceptor')/g" src/views/LoginRegister.vue | |
npm install | |
npm run dev & | |
for attempt in {1..20}; do sleep 2; if curl -s http://localhost:5173/ > /dev/null; then break; fi; done | |
- name: Run cypress tests | |
uses: cypress-io/github-action@v6 | |
with: | |
wait-on: 'http://localhost:5173, http://localhost:6002, http://localhost:5001' | |
spec: cypress/e2e/wgp/*.cy.js |