diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 215a5d6e..9e4be9c3 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,22 +1,15 @@ -name: Continuous integration +name: CI on: - pull_request: push: - branches: - - main - tags: - - 'release-*' + branches: [main] + pull_request: + branches: [main] + workflow_dispatch: jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 22 - - run: yarn - - run: yarn lint - - run: yarn test - - run: yarn build + common: + uses: City-of-Helsinki/.github/.github/workflows/ci-node.yml@main + secrets: inherit + with: + node-version: 22 diff --git a/.github/workflows/npm-publish-canary.yml b/.github/workflows/npm-publish-canary.yml index 0326f2b1..438a0a90 100644 --- a/.github/workflows/npm-publish-canary.yml +++ b/.github/workflows/npm-publish-canary.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: 20 + node-version: 22 registry-url: https://registry.npmjs.org/ - run: yarn - run: yarn test diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7a43f888..f4d4488e 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,21 +1,16 @@ -name: publish +name: npm publish on: - release: - types: [created] + push: + tags: + - 'v*.*.*' # Trigger on version tags jobs: - publish-npm-stable: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v1 - with: - node-version: 20 - registry-url: https://registry.npmjs.org/ - - run: yarn - - run: yarn test - - run: yarn build - - run: yarn publish-stable - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + publish: + uses: City-of-Helsinki/.github/.github/workflows/ci-npm-publish.yml@main + with: + node-version: '22' + package-manager: 'yarn' + install-command: 'yarn --frozen-lockfile' + test-command: 'yarn test' + build-command: 'yarn build' \ No newline at end of file diff --git a/.gitignore b/.gitignore index ac870a9a..043eda17 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ react-helsinki-headless-cms.iml dist storybook-static -.env \ No newline at end of file +.env +coverage diff --git a/package.json b/package.json index 3ae36d9d..470509fe 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "lint-fix": "yarn eslint \"src/**/*.{ts,tsx}\" --fix && yarn prettier ./src -w", "test": "jest", "test-storybook": "test-storybook", + "test:coverage": "jest --coverage", "build": "rollup -c --bundleConfigAsCjs", "docker:dev": "cross-env DOCKER_TARGET=development docker compose up", "docker:prod": "cross-env DOCKER_TARGET=production docker compose up", diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..31a784be --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,19 @@ +sonar.projectKey=city-of-helsinki_react-helsinki-headless-cms +sonar.organization=city-of-helsinki +sonar.projectName=react-helsinki-headless-cms + +# Path is relative to the sonar-project.properties file. Defaults to . +sonar.sources=src + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 + +# Paths to exclude from analysis +sonar.exclusions=**/node_modules/**,**/dist/**,**/lib/**,**/coverage/**,**/.storybook/**,**/scripts/**,**/*.d.ts + +# Paths to test files +sonar.tests=src +sonar.test.inclusions=src/**/*.test.ts,src/**/*.test.tsx,src/**/__tests__/**/*.{ts,tsx} + +# Coverage report +sonar.javascript.lcov.reportPaths=coverage/lcov.info