Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nx migration and angular update #137

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
72f2fe8
Update to angular 13
edlu77 Feb 2, 2024
5c46d67
Update packages and theming
edlu77 Feb 2, 2024
7ce9011
More updates
edlu77 Feb 2, 2024
62b1c02
Fix lint error
edlu77 Feb 2, 2024
887f83c
Update workflows yml
edlu77 Feb 2, 2024
3c3cdbe
Update workflows yaml
edlu77 Feb 3, 2024
90ce9ae
Upgrade to Angular 14
edlu77 Feb 5, 2024
ee3782c
Update to Angular 15
edlu77 Feb 5, 2024
06e2b4d
Upgrade to angular 15
edlu77 Feb 5, 2024
be5ec2d
Update packages
edlu77 Feb 5, 2024
dde7482
Update to standalone ngx-vega component
edlu77 Feb 6, 2024
c86fba0
Upgrade to Angular 17
edlu77 Feb 6, 2024
142d934
Fix linting
edlu77 Feb 6, 2024
2f83ee8
Remove empty tests
edlu77 Feb 6, 2024
08cfdeb
Fix opioid misspelling
edlu77 Feb 7, 2024
fdc92d0
Fix issue in vis3
edlu77 Feb 7, 2024
93ed939
Update some angular material components
edlu77 Feb 8, 2024
0d28078
Upgrade all material components to current version
edlu77 Feb 8, 2024
90435e8
Remove unneeded css
edlu77 Feb 8, 2024
1940731
Add nx
edlu77 Feb 13, 2024
9cb7db9
Update workflows
edlu77 Feb 13, 2024
762c165
Add actions
edlu77 Feb 13, 2024
417bf71
Update actions
edlu77 Feb 13, 2024
f31c73b
Update workflows
edlu77 Feb 13, 2024
a99de87
Update yml
edlu77 Feb 13, 2024
3b8b2d7
Update yml
edlu77 Feb 13, 2024
3ce5b1b
install nx cloud
edlu77 Feb 13, 2024
008961a
Update nx.json
edlu77 Feb 13, 2024
65d369d
Update files
edlu77 Feb 13, 2024
b503133
Rearrange file structure
edlu77 Feb 14, 2024
f48b286
Update workflows
edlu77 Feb 14, 2024
afb93fd
Update files
edlu77 Feb 14, 2024
6cf8446
Use older versions
edlu77 Feb 15, 2024
f4612a3
changes to eslint file
edlu77 Feb 15, 2024
35c6651
Formatting fixes
edlu77 Feb 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
File renamed without changes.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
36 changes: 36 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"destructuredArrayIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrors": "all"
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
},
{
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
"env": {
"jest": true
},
"rules": {}
}
],
"extends": ["plugin:storybook/recommended"]
}
37 changes: 37 additions & 0 deletions .github/actions/deploy-comment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Create Deploy Comment
description: Creates and Updates the deploy Comment
inputs:
deploy-url:
description: Url for deployed preview
required: true
runs:
using: composite
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: 'fc'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '# :rocket: Preview Deploy Report'

- name: Create Comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
# :rocket: Preview Deploy Report

✅ Successfully deployed preview [here](${{ inputs.deploy-url }})

- name: Update Comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{steps.fc.outputs.comment-id}}
edit-mode: replace
body: |
# :rocket: Preview Deploy Report Updated

✅ Successfully deployed preview [here](${{ inputs.deploy-url }})
75 changes: 75 additions & 0 deletions .github/actions/prepare-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Prepare a deploy build
description: Build apps, storybook, and compodoc and generates deploy files

inputs:
main-branch-name:
description: Main branch name against which nx builds
required: true
app-configuration:
description: App build target configuration
required: true
nx-command:
description: Command used to build artifacts ('affected' or 'run-many')
required: false
default: affected
deploy-directory:
description: Deployment directory
required: false
default: deploy
skip-node-js:
description: Skip Node.js setup
required: false
default: 'false'
build-compodoc:
description: Whether to build code documentation
required: false
default: 'true'
build-storybook:
description: Whether to build storybook
required: false
default: 'true'

runs:
using: composite
steps:
- name: Node.js setup
if: ${{ inputs.skip-node-js == 'false' }}
uses: ./.github/actions/setup-node-js
- name: Configure nx
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: ${{ inputs.main-branch-name }}

- name: Build apps
shell: bash
run: npx nx ${{ inputs.nx-command }} --targets=build --configuration=${{ inputs.app-configuration }}
- name: Build compodoc
if: ${{ inputs.build-compodoc == 'true' }}
shell: bash
run: npx nx ${{ inputs.nx-command }} --targets=compodoc --configuration=ci

- name: Build storybook
if: ${{ inputs.build-storybook == 'true' }}
shell: bash
run: |
# Run one at a time due to https://github.com/nrwl/nx/issues/6842
# Will hopefully be fixed by backport of https://github.com/storybookjs/storybook/pull/19307
npx nx ${{ inputs.nx-command }} --targets=build-storybook --configuration=ci --parallel=false
env:
STORYBOOK_DISABLE_TELEMETRY: '1'

- name: Collect artifacts
id: collect
shell: bash
run: ${{ github.action_path }}/collect_artifacts.sh ${{ inputs.deploy-directory }} dist/{apps,compodoc,storybook}

- name: Generate index file
uses: cuchi/[email protected]
with:
template: ${{ github.action_path }}/index.html.j2
output_file: ${{ inputs.deploy-directory }}/index.html
strict: true
variables: |
apps=${{ steps.collect.outputs.apps }}
storybook=${{ inputs.build-storybook == 'true' && steps.collect.outputs.storybook || '' }}
compodoc=${{ inputs.build-compodoc == 'true' && steps.collect.outputs.compodoc || '' }}
40 changes: 40 additions & 0 deletions .github/actions/prepare-deploy/collect_artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash
#
# Collects built artifacts and moves them to the specified directory
# Arguments:
# Output directory
# One or more input directories to search
# Outputs:
# Writes an output for each input directory to github outputs
# Each entry contains the name of the directory as the key and
# a comma separated list of copied directories as the value

shopt -s extglob

#######################################
# Main logic
#######################################
out_dir="$1"
mkdir -p "${out_dir}"
shift

while (( "$#" )); do
if [[ -d $1 ]]; then
# Extract directory name (https://stackoverflow.com/a/1371283)
dir_name="${1%%+(/)}"
dir_name="${dir_name##*/}"
dir_name="${dir_name:-/}"

# Copy directory
cp -r "$1" "${out_dir}"

# List subdirectories as a comma separated list
sub_dirs=$(echo "${out_dir}/${dir_name}"/*)
sub_dirs="${sub_dirs[*]//$out_dir\/}"
sub_dirs="${sub_dirs[*]//$' '/,}"

# Write outputs
echo "${dir_name}=${sub_dirs}" >> "${GITHUB_OUTPUT}"
fi
shift
done
34 changes: 34 additions & 0 deletions .github/actions/prepare-deploy/index.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!doctype html>
<html>
<head>
<title>Build preview for {{ env['GITHUB_REF_NAME'] }}</title>
</head>
<body>
{% macro createLinkEntry(dir) %}
<li>
<a href="{{ dir }}/index.html">{{ dir.split('/')[-1] }}</a>
</li>
{% endmacro %}

{% macro createLinks(header, dirs_str) %}
{% if dirs_str %}
<h1>{{ header }}</h1>
<ul>
{% for dir in dirs_str.split(',') %}
{{ createLinkEntry(dir) }}
{% endfor %}
</ul>
{% endif %}
{% endmacro %}

{% if not (apps or storybook or compodoc) %}
<p>
No app, storybook, or compodoc were affected by the current changes!
</p>
{% endif %}

{{ createLinks('Apps', apps) }}
{{ createLinks('Storybook', storybook) }}
{{ createLinks('Compodoc', compodoc) }}
</body>
</html>
33 changes: 33 additions & 0 deletions .github/actions/setup-node-js/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Setup node environment
description: Install Node.js and all dependencies using the cache when available

inputs:
node-version:
description: Node.js version
required: false
default: '16'

runs:
using: composite
steps:
- name: Use Node.js ${{ inputs.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
- name: Cache .npm
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache node_modules
id: modules_cache
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
shell: bash
if: ${{ steps.modules_cache.outputs.cache-hit != 'true' }}
run: npm ci --ignore-scripts
46 changes: 23 additions & 23 deletions .github/workflows/build-previews.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
name: 'Netlify Preview Deploy'
name: Netlify Preview Deploy

on:
pull_request:
types: ['opened', 'edited', 'synchronize']

concurrency:
group: preview-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
deploy:
name: 'Deploy'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
- uses: actions/checkout@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
fetch-depth: 0

- name: Prepare Deploy
uses: ./.github/actions/prepare-deploy
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: npm ci for website
run: npm ci
working-directory: website
- run: npm run build -- --output-hashing=none --base-href=/
working-directory: website
main-branch-name: develop
app-configuration: preview

- uses: jsmrcaga/action-netlify-deploy@master
- name: Publish
id: deploy
uses: netlify/actions/cli@master
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
args: deploy --dir=deploy --filter=ftu-ui
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
install_command: false
build_command: false
build_directory: website/dist/a2agc
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}

- name: Create Deploy Comment
uses: ./.github/actions/deploy-comment
with:
deploy-url: ${{steps.deploy.outputs.NETLIFY_URL}}
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:

concurrency:
group: ci-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
main:
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/[email protected]
with:
number-of-agents: 3
init-commands: |
npx nx-cloud start-ci-run --stop-agents-after="build" --agent-count=3
parallel-commands: |
npx nx-cloud record -- npx nx format:check
parallel-commands-on-agents: |
npx nx affected --target=lint --parallel=3
npx nx affected --target=test --parallel=3 --ci --code-coverage
npx nx affected --target=test-doc-coverage --parallel=3
npx nx affected --target=build --parallel=3
main-branch-name: develop

agents:
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/[email protected]
with:
number-of-agents: 3

slack-notification:
name: Slack Notification
if: ${{ always() }}
runs-on: ubuntu-latest
needs: main
steps:
- uses: kpritam/slack-job-status-action@v1
with:
job-status: ${{ needs.main.result }}
slack-bot-token: ${{ secrets.SLACK_BOT_TOKEN }}
channel: github
Loading
Loading