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

monorepo #2500

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
152 changes: 152 additions & 0 deletions .github/workflows/build-npm-components.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# This workflow will do a clean install of node dependencies, build the source code,
# run unit tests, and perform a SonarCloud scan.

# For more information see:
# https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

# Common FOLIO configurable env:
# - YARN_TEST_OPTIONS (options to pass to 'yarn test')
# - SQ_ROOT_DIR (where to scan relative to top-level directory)
# - FOLIO_NAME
# - PUBLISH_MOD_DESCRIPTOR (boolean 'true' or 'false')
# - COMPILE_TRANSLATION_FILES (boolean 'true' or 'false')



name: buildNPM Snapshot (users-components)
on: [push, pull_request]
jobs:
build-npm:
defaults:
run:
working-directory: ./users-components
env:
YARN_TEST_OPTIONS: '--ci --coverage --colors'
SQ_ROOT_DIR: './users-components/src'
PUBLISH_MOD_DESCRIPTOR: 'true'
COMPILE_TRANSLATION_FILES: 'true'
FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/'
FOLIO_NPM_REGISTRY_AUTH: '//repository.folio.org/repository/npm-folioci/'
FOLIO_MD_REGISTRY: 'https://folio-registry.dev.folio.org'
NODEJS_VERSION: '16'
JEST_JUNIT_OUTPUT_DIR: 'artifacts/jest-junit'
JEST_COVERAGE_REPORT_DIR: 'artifacts/coverage-jest/lcov-report/'
SQ_LCOV_REPORT: 'artifacts/coverage-jest/lcov.info'
SQ_EXCLUSIONS: '**/platform/alias-service.js,**/docs/**,**/node_modules/**,**/examples/**,**/artifacts/**,**/ci/**,Jenkinsfile,**/LICENSE,**/*.css,**/*.md,**/*.json,**/tests/**,**/stories/*.js,**/test/**,**/.stories.js,**/resources/bigtest/interactors/**,**/resources/bigtest/network/**,**/*-test.js,**/*.test.js,**/*-spec.js,**/karma.conf.js,**/jest.config.js'

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup kernel for react native, increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODEJS_VERSION }}
check-latest: true
always-auth: true

- name: Set yarn config
working-directory: .
run: yarn config set @folio:registry $FOLIO_NPM_REGISTRY

- name: Run yarn install
working-directory: .
run: yarn install --ignore-scripts --frozen-lockfile

- name: Run yarn list
run: yarn list --pattern @folio

- name: Set FOLIO NPM snapshot version
run: |
git clone https://github.com/folio-org/folio-tools.git
npm --no-git-tag-version version `folio-tools/github-actions-scripts/folioci_npmver.sh`
rm -rf folio-tools
env:
JOB_ID: ${{ github.run_number }}

- name: Run yarn lint
run: yarn lint
continue-on-error: true

- name: Get number of CPU cores
id: cpu-cores
uses: SimenB/github-actions-cpu-cores@v1

- name: Run yarn test
run: xvfb-run --server-args="-screen 0 1024x768x24" yarn test $YARN_TEST_OPTIONS --max-workers ${{ steps.cpu-cores.outputs.count }}

- name: Upload event file
uses: actions/upload-artifact@v3
with:
name: Event File
path: ${{ github.event_path }}
retention-days: 30

- name: Upload Jest results
if: always()
uses: actions/upload-artifact@v3
with:
name: jest-test-results
path: ${{ env.JEST_JUNIT_OUTPUT_DIR }}/*.xml
retention-days: 30

- name: Publish Jest coverage report
uses: actions/upload-artifact@v2
if: always()
with:
name: jest-coverage-report
path: ${{ env.JEST_COVERAGE_REPORT_DIR }}
retention-days: 30

- name: Set default branch as env variable
run: echo "DEFAULT_BRANCH=${{ github.event.repository.default_branch }}" >> $GITHUB_ENV

- name: Fetch branches for SonarCloud
run: git fetch --no-tags ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} +refs/heads/${{ env.DEFAULT_BRANCH }}:refs/remotes/origin/${{ env.DEFAULT_BRANCH }}

- name: Run SonarCloud scan
uses: sonarsource/[email protected]
with:
args: >
-Dsonar.organization=folio-org
-Dsonar.projectKey=org.folio:${{ github.event.repository.name }}
-Dsonar.projectName=${{ github.event.repository.name }}
-Dsonar.sources=${{ env.SQ_ROOT_DIR }}
-Dsonar.language=js
-Dsonar.javascript.lcov.reportPaths=${{ env.SQ_LCOV_REPORT }}
-Dsonar.exclusions=${{ env.SQ_EXCLUSIONS }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

- name: Set up NPM environment for publishing
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODEJS_VERSION }}
check-latest: true
always-auth: true

- name: Set _auth in .npmrc
run: |
npm config set @folio:registry $FOLIO_NPM_REGISTRY
npm config set $FOLIO_NPM_REGISTRY_AUTH:_auth $NODE_AUTH_TOKEN
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Exclude some CI-generated artifacts in package
run: |
echo "artifacts" >> .npmignore
echo ".github" >> .npmignore
echo ".scannerwork" >> .npmignore
cat .npmignore

- name: Publish NPM
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
21 changes: 13 additions & 8 deletions .github/workflows/build-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@



name: buildNPM Snapshot
name: buildNPM Snapshot (users)
on: [push, pull_request]
jobs:
build-npm:
defaults:
run:
working-directory: ./users
env:
YARN_TEST_OPTIONS: '--ci --coverage --colors'
SQ_ROOT_DIR: './src'
SQ_ROOT_DIR: './users/src'
PUBLISH_MOD_DESCRIPTOR: 'true'
COMPILE_TRANSLATION_FILES: 'true'
FOLIO_NPM_REGISTRY: 'https://repository.folio.org/repository/npm-folioci/'
Expand Down Expand Up @@ -47,8 +50,16 @@ jobs:
always-auth: true

- name: Set yarn config
working-directory: .
run: yarn config set @folio:registry $FOLIO_NPM_REGISTRY

- name: Run yarn install
working-directory: .
run: yarn install --ignore-scripts --frozen-lockfile

- name: Run yarn list
run: yarn list --pattern @folio

- name: Set FOLIO NPM snapshot version
run: |
git clone https://github.com/folio-org/folio-tools.git
Expand All @@ -57,12 +68,6 @@ jobs:
env:
JOB_ID: ${{ github.run_number }}

- name: Run yarn install
run: yarn install --ignore-scripts --frozen-lockfile

- name: Run yarn list
run: yarn list --pattern @folio

- name: Run yarn lint
run: yarn lint
continue-on-error: true
Expand Down
Loading