Skip to content

Fix runtime error of production Graph API client #256

Fix runtime error of production Graph API client

Fix runtime error of production Graph API client #256

Workflow file for this run

# Copyright 2024 Jiaqi Liu. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
name: CI/CD
"on":
pull_request:
push:
branches:
- master
repository_dispatch:
types: [runbook-changes]
env:
USER: QubitPi
EMAIL: jack20220723@gmail.com
NODE_VERSION: 18
jobs:
cancel-previous:
name: Cancel Previous Runs In Order to Allocate Action Resources Immediately for Current Run
runs-on: ubuntu-latest
steps:
- name: Cancel previous
uses: styfle/cancel-workflow-action@0.10.1
if: ${{github.ref != 'refs/head/master'}}
with:
access_token: ${{ github.token }}
yml-md-style:
uses: QubitPi/hashicorp-aws/.github/workflows/yml-md-style-and-link-checks.yml@master
code-style:
name: React & TS Code Style Check
uses: QubitPi/hashicorp-aws/.github/workflows/ui-code-style.yml@master
with:
node-version: 18
unit-tests:
name: Unit Tests
needs: [yml-md-style, code-style]
uses: QubitPi/hashicorp-aws/.github/workflows/ui-unit-test.yml@master
with:
node-version: 18
test-ai:
name: Integration Test on Dev AI server
needs: [yml-md-style, code-style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set node version to ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn
- name: Start dev AI server
run: yarn start:ai &
- name: Wait until dev AI server is up
run: yarn wait-on-ai
- name: Run tests
run: |
curl localhost:3001/nodes > actual-nodes.json
curl localhost:3001/links > actual-links.json
echo "" >> actual-nodes.json
echo "" >> actual-links.json
diff .github/ai/expected-nodes.json actual-nodes.json
diff .github/ai/expected-links.json actual-links.json
list-e2e-specs:
needs: [unit-tests, test-ai]
runs-on: ubuntu-latest
outputs:
paths: ${{ steps.list-e2e-specs.outputs.paths }}
steps:
- name: List Files
id: list-e2e-specs
uses: mirko-felice/list-files-action@v3.0.5
with:
repo: ${{ github.repository }}
ref: ${{ github.ref }}
path: "cypress/e2e"
ext: ".ts"
e2e-tests:
name: E2E Tests
needs: list-e2e-specs
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_spec: ${{ fromJson(needs.list-e2e-specs.outputs.paths) }}
start_strategy: ["yarn-start", "serve"]
node_version: [18]
steps:
- uses: actions/checkout@v3
- name: Set node version to ${{ env.NODE_VERSION }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: yarn
- name: Load test .env file
run: mv .env.test .env
- name: Start test NLP service
run: |
yarn start:ai &
yarn wait-on-ai
- name: Start test Graph API service
run: |
yarn start:graph-api &
cd scripts
timeout 1m bash -c 'until ./remove-graph.sh; do sleep 3; done'
cd ../
- uses: QubitPi/hashicorp-aws/.github/actions/cypress-e2e@master
with:
node-version: ${{ env.NODE_VERSION }}
start-strategy: ${{ matrix.start_strategy }}
spec-relative-path: ${{ matrix.test_spec }}
- run: npm exec -- argos upload --token ${{ secrets.ARGOS_TOKEN }} cypress/screenshots
lighthouse:
if: github.ref != 'refs/heads/master'
needs: [yml-md-style, code-style]
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Load test .env file
run: cp .env.dev .env && yarn
- name: Audit URLs using Lighthouse
id: lighthouse_audit
uses: treosh/lighthouse-ci-action@v10
with:
urls: |
http://localhost:3000
uploadArtifacts: true
temporaryPublicStorage: true
budgetPath: ./.github/lighthouse/lighthouse-budget.json
configPath: ./.github/lighthouse/lighthouserc.json
- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # 7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = ${{ steps.lighthouse_audit.outputs.manifest }}
const links = ${{ steps.lighthouse_audit.outputs.links }}
const createLighthouseReport = (await import(`${process.env.GITHUB_WORKSPACE}/.github/lighthouse/formatLighthouseReport.js`)).default;
const comment = createLighthouseReport({ results, links });
core.setOutput("comment", comment);
- name: Add Lighthouse stats as comment
id: comment_to_pr
uses: marocchino/sticky-pull-request-comment@efaaab3fd41a9c3de579aba759d2552635e590fd # 2.8.0
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.format_lighthouse_score.outputs.comment }}
json-scheam-test:
name: Check JSON schema syntax
needs: [yml-md-style, code-style]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: json-syntax-check
uses: limitusus/json-syntax-check@v2
with:
pattern: "packages/nexusgraph-db/graph.schema"
documentation:
name: Test and Deploy Documentation to GitHub Pages
needs: e2e-tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Install nexusgraph dependencies so that TypeDoc process source files properly
run: cd ../ && yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Install doc dependencies
run: yarn install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Build documentation
run: yarn build
- name: Load CNAME
run: cp CNAME build/
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
enable_jekyll: false
user_name: ${{ env.USER }}
user_email: ${{ env.EMAIL }}
npm-release:
name: Publish Nexus Graph to NPM
needs: e2e-tests
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: QubitPi/hashicorp-aws/.github/actions/npm-release@master
with:
user: ${{ env.USER }}
email: ${{ env.EMAIL }}
npm-token: ${{ secrets.NPM_TOKEN }}
node-version: ${{ env.NODE_VERSION }}