Skip to content

Commit

Permalink
Merge pull request #1081 from IntersectMBO/develop
Browse files Browse the repository at this point in the history
Cardano Stack: Node Version Upgrade, Various Enhancements, Fixes, Test Updates
  • Loading branch information
pmbinapps authored May 23, 2024
2 parents b064ed3 + ee9f104 commit 6d2bfb4
Show file tree
Hide file tree
Showing 125 changed files with 4,473 additions and 1,488 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/build-and-deploy-test-stack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build and deploy GovTool test stack
run-name: Deploy by @${{ github.actor }}

on:
push:
branches:
- test

env:
ENVIRONMENT: "test"
CARDANO_NETWORK: "sanchonet"

jobs:
deploy:
name: Deploy app
runs-on: ubuntu-latest
env:
GRAFANA_ADMIN_PASSWORD: ${{ secrets.GRAFANA_ADMIN_PASSWORD }}
GRAFANA_SLACK_RECIPIENT: ${{ secrets.GRAFANA_SLACK_RECIPIENT }}
GRAFANA_SLACK_OAUTH_TOKEN: ${{ secrets.GRAFANA_SLACK_OAUTH_TOKEN }}
SENTRY_DSN_BACKEND: ${{ secrets.SENTRY_DSN_BACKEND }}
GTM_ID: ${{ secrets.GTM_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN_FRONTEND }}
PIPELINE_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
USERSNAP_SPACE_API_KEY: ${{ secrets.USERSNAP_SPACE_API_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup SSH agent
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.TEST_STACK_SSH_KEY }}

- name: Run Ansible playbook
uses: dawidd6/action-ansible-playbook@v2
with:
playbook: playbook.yml
directory: ./tests/test-infrastructure
key: ${{ secrets.TEST_STACK_SSH_KEY }}
inventory: |
[test_server]
${{ secrets.TEST_STACK_SERVER_IP }} ansible_user=ec2-user
options: |
--verbose
env:
GOVTOOL_TAG: ${{ github.sha }}
40 changes: 11 additions & 29 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,32 @@
name: Lighthouse

on:
push:
paths:
- govtool/frontend/**
- .github/workflows/lighthouse.yml
workflow_run:
workflows:
- Build and deploy GovTool test stack
types:
- completed
workflow_dispatch:

jobs:
lighthouse:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max_old_space_size=4096
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: npm install
working-directory: ./govtool/frontend

- name: Cache npm dependencies
id: npm-cache
uses: actions/cache@v3
with:
path: |
~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('govtool/frontend/package-lock.json', 'tests/govtool-frontend/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- run: npm install -g @lhci/[email protected]

- name: Run build and lighthouse task
- name: Run lighthouse task
working-directory: ./govtool/frontend
run: |
npm install
VITE_BASE_URL=https://staging.govtool.byron.network/ npm run build
lhci collect
- name: Evaluate reports
if: github.repository_owner != 'IntersectMBO'
working-directory: ./govtool/frontend
run: |
lhci assert --preset "lighthouse:recommended"
Expand All @@ -50,9 +35,6 @@ jobs:
if: github.repository_owner == 'IntersectMBO'
run: |
lhci assert --preset lighthouse:recommended || echo "LightHouse Assertion error ignored ..."
lhci upload --githubAppToken="${{ secrets.LHCI_GITHUB_APP_TOKEN }}" --token="${{ secrets.LHCI_SERVER_TOKEN }}" --serverBaseUrl=https://lighthouse.cardanoapi.io --ignoreDuplicateBuildFailure
curl -X POST https://ligththouse.cardanoapi.io/api/metrics/build-reports \
-d "@./lighthouseci/$(ls ./.lighthouseci |grep 'lhr.*\.json' | head -n 1)" \
-H "commit-hash: $(git rev-parse HEAD)" \
-H "secret-token: ${{ secrets.METRICS_SERVER_SECRET_TOKEN }}" \
-H 'Content-Type: application/json' || echo "Metric Upload error ignored ..."
lhci upload --githubAppToken="${{ secrets.LHCI_GITHUB_APP_TOKEN }}" --token="${{ secrets.LHCI_SERVER_TOKEN }}" --serverBaseUrl=${LHCI_SERVER_URL} --ignoreDuplicateBuildFailure
env:
LHCI_SERVER_URL: https://lighthouse-govtool.cardanoapi.io
30 changes: 12 additions & 18 deletions .github/workflows/test_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,18 @@ name: Backend Test

on:
push:
paths:
- .github/workflows/test_backend.yml
# - govtool/backend
# - tests/govtool-backend

schedule:
- cron: "0 0 * * *"
branches:
- test
workflow_dispatch:
inputs:
deployment:
required: true
type: choice
default: "staging.govtool.byron.network/api"
default: "govtool.cardanoapi.io/api"
options:
- "sanchogov.tools/api"
- "staging.govtool.byron.network/api"
- "govtool-sanchonet.cardanoapi.io/api"
- "govtool.cardanoapi.io/api"

jobs:
backend-tests:
Expand All @@ -38,15 +33,15 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python ./setup.py
python -m pytest --alluredir allure-results
env:
BASE_URL: https://${{inputs.deployment || 'staging.govtool.byron.network/api' }}
METRICS_URL: https://metrics.cardanoapi.io
METRICS_API_SECRET: "${{ secrets.METRICS_SERVER_SECRET_TOKEN }}"
BASE_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io/api' }}
FAUCET_API_KEY: ${{ secrets.FAUCET_API_KEY }}
KUBER_API_URL: https://kuber-govtool.cardanoapi.io

- name: Upload report
uses: actions/upload-artifact@v3
if: always()
with:
name: allure-results
path: tests/govtool-backend/allure-results
Expand All @@ -70,7 +65,7 @@ jobs:
ref: gh-pages
path: gh-pages
repository: ${{vars.GH_PAGES}}
token: ${{secrets.PERSONAL_TOKEN}}
ssh-key: ${{ secrets.DEPLOY_KEY }}

- name: Register report
id: register-project
Expand All @@ -81,7 +76,7 @@ jobs:
- if: steps.register-project.outputs.project_exists != 'true'
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
ssh-key: ${{ secrets.DEPLOY_KEY }}
repository-name: ${{vars.GH_PAGES}}
branch: gh-pages
folder: project
Expand All @@ -94,7 +89,6 @@ jobs:
- name: Build report
uses: simple-elf/allure-report-action@master
if: always()
id: allure-report
with:
allure_results: allure-results
Expand All @@ -113,12 +107,12 @@ jobs:
- name: Deploy report to Github Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
ssh-key: ${{ secrets.DEPLOY_KEY }}
repository-name: ${{vars.GH_PAGES}}
branch: gh-pages
folder: build
target-folder: ${{ env.REPORT_NAME }}

env:
REPORT_NAME: backend
REPORT_NAME: govtool-backend
GH_PAGES: ${{vars.GH_PAGES}}
71 changes: 0 additions & 71 deletions .github/workflows/test_integration_cypress.yml

This file was deleted.

31 changes: 23 additions & 8 deletions .github/workflows/test_integration_playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@ name: Integration Test [Playwright]

on:
push:
paths:
- .github/workflows/test_integration_playwright.yml
branches:
- test
workflow_dispatch:
inputs:
deployment:
required: true
type: choice
default: "govtool.cardanoapi.io"
options:
- "sanchogov.tools"
- "staging.govtool.byron.network"
- "govtool.cardanoapi.io"

workflow_run:
workflows: ["Build and deploy GovTool to TEST server"]
types: [completed]

jobs:
integration-tests:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }}
defaults:
run:
working-directory: tests/govtool-frontend/playwright
Expand Down Expand Up @@ -40,6 +50,9 @@ jobs:

- name: Run tests
run: |
mkdir -p ./lib/_mock
chmod +w ./lib/_mock
npm run generate-wallets
npm test
- name: Upload report
Expand All @@ -50,18 +63,20 @@ jobs:
path: tests/govtool-frontend/playwright/allure-results

env:
FRONTEND_URL: ${{vars.HOST_URL}}
API_URL: ${{vars.HOST_URL}}/api
HOST_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}
API_URL: https://${{inputs.deployment || 'govtool.cardanoapi.io' }}/api
DOCS_URL: ${{ vars.DOCS_URL }}
FAUCET_API_URL: ${{ vars.FAUCET_API_URL }}
FAUCET_API_KEY: ${{secrets.FAUCET_API_KEY}}
KUBER_API_URL: ${{vars.KUBER_API_URL}}
KUBER_API_KEY: ${{secrets.KUBER_API_KEY}}
WORKERS: ${{vars.TEST_WORKERS}}
TEST_WORKERS: ${{vars.TEST_WORKERS}}
CI: ${{vars.CI}}
CARDANOAPI_METADATA_URL: ${{vars.CARDANOAPI_METADATA_URL}}

publish-report:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'push' }}
if: always()
needs: integration-tests
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -128,5 +143,5 @@ jobs:
target-folder: ${{ env.REPORT_NAME }}

env:
REPORT_NAME: integration
REPORT_NAME: govtool-frontend
GH_PAGES: ${{vars.GH_PAGES}}
2 changes: 1 addition & 1 deletion generate_latest_report_redirect.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cat <<EOF > build/index.html
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=/$allure_report_path/$REPORT_NAME/$REPORT_NUMBER">
<meta http-equiv="refresh" content="0; url=/$allure_report_path/$REPORT_NAME/$REPORT_NUMBER#behaviors">
<title>Redirecting...</title>
</head>
</html>
Expand Down
4 changes: 0 additions & 4 deletions gov-action-loader/backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
KUBER_API_URL=https://sanchonet.kuber.cardanoapi.io
KUBER_API_KEY=xxxxxxxxxxxxx

## Not required anymore
BLOCKFROST_API_URL=
BLOCKFROST_PROJECT_ID=
6 changes: 1 addition & 5 deletions gov-action-loader/backend/app/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

class Settings(BaseSettings):
kuber_api_url: str
kuber_api_key: str

blockfrost_api_url: str
blockfrost_project_id: str

kuber_api_key: str = ''

settings = Settings()
Loading

0 comments on commit 6d2bfb4

Please sign in to comment.