Skip to content

Commit

Permalink
Monorepo Build Tooling (#156)
Browse files Browse the repository at this point in the history
* nx integrated monorepo

* rebuild package-lock

* migrated documentation app

* renamed tsconfig.json files to fix vscode errors

* changed library path to index.ts

* fixed some import paths

* fixed import path

* fixed default theme paths

* import karma.base.conf in root karma.conf

* fixed tsconfig.prod

* fix vscode type errors for merged interface declaration

* updated readme

* fixed Dockerfile

* update angular to fix bundle size issue

* code formatting

* added deploy target, updated github workflows

* require format check before deploy

* setup node before format check

* npm ci before format check

* removed unnecessary npm scripts

* fetch depth for format check

* set shas for format check

* removed watch step from readme

* fixed library dest dir

* fixed documentation app

* updated repository.directory in package.json

* moved sort-datasets.pipe.ts

* code formatting

* code formatting

* code formatting

* code formatting
  • Loading branch information
semicolin authored Apr 4, 2023
1 parent 36783cd commit 46c14f9
Show file tree
Hide file tree
Showing 322 changed files with 18,483 additions and 31,009 deletions.
142 changes: 0 additions & 142 deletions .github/workflows/build-test.js.yml

This file was deleted.

21 changes: 0 additions & 21 deletions .github/workflows/npm-publish.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Pull Request

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

permissions:
pull-requests: read # allows SonarCloud to decorate PRs with analysis results

env:
NODE_VERSION: 18.x

jobs:
format:
name: Code Formatting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: npm ci
- run: npx nx format:check

build-affected:
name: Production Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: npm ci
- run: npx nx affected -t build --parallel=5

test-affected:
name: Test and Scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: npm ci
- run: npx nx affected -t test --parallel=5 --no-watch --code-coverage
- name: Analyze with SonarCloud
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} # Generate a token on Sonarcloud.io, add it to the secrets of this repo with the name SONAR_TOKEN (Settings > Secrets > Actions > add new repository secret)
with:
args:
# Unique keys of your project and organization. You can find them in SonarCloud > Information (bottom-left menu)
# mandatory
-Dsonar.projectKey=elimuinformatics_charts-on-fhir
-Dsonar.organization=elimuinformatics-1
-Dsonar.javascript.lcov.reportPaths=coverage/**/lcov.info
-Dsonar.coverage.exclusions=**/*.spec.ts,**/test.ts,**/main.ts,**/polyfills.ts,**/*.module.ts,**/environment*.ts,**/*.js,projects/synthea-utils/*,apps/documentation/**/*
-Dsonar.test.inclusions=**/*.spec.ts,**/test.ts

deploy-affected:
name: Deploy Applications
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- format
- test-affected
- build-affected
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: nrwl/nx-set-shas@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: npm ci
- run: npx nx affected -t deploy --parallel=5
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release

on:
release:
types: [published]

env:
NODE_VERSION: 18.x

jobs:
publish:
name: Publish to NPM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: https://registry.npmjs.org/
cache: npm
- run: npm ci
- run: npm run build ngx-charts-on-fhir
- run: npm publish dist/libs/ngx-charts-on-fhir/ --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

build-docs:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- run: npm ci
- run: npm run build documentation -- --base-href=/charts-on-fhir/
- run: cp dist/apps/documentation/index.html dist/apps/documentation/404.html # Needed for Angular routing
- uses: actions/upload-pages-artifact@main
with:
path: dist/apps/documentation

deploy-docs:
name: Publish Documentation
needs: build-docs
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
dist
coverage
node_modules
.github/pull_request_template.md
.github/pull_request_template.md
.ng-doc
**/synthea-utils/**/*.json
**/mock-fhir-server/**/*.json
3 changes: 1 addition & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
"recommendations": ["angular.ng-template"]
"recommendations": ["angular.ng-template", "nrwl.angular-console", "dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
}
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ WORKDIR /home/node
COPY --chown=node package*.json ./
RUN npm ci
COPY --chown=node . .
RUN npm run build ngx-charts-on-fhir
ARG project
RUN npm run build ${project}
ARG app
RUN npm run build ${app}

### STAGE 2: Run on nginx ###
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY nginx.conf /etc/nginx/
COPY ./docker-entrypoint.sh /etc/nginx/
ARG project
COPY --from=build /home/node/dist/${project} /usr/share/nginx/html
ARG app
COPY --from=build /home/node/dist/apps/${app} /usr/share/nginx/html
ENTRYPOINT ["/etc/nginx/docker-entrypoint.sh"]
CMD ["nginx"]
Loading

0 comments on commit 46c14f9

Please sign in to comment.