Skip to content

Commit

Permalink
Merge pull request #141 from fingerprintjs/feature/INTER-166-shared-w…
Browse files Browse the repository at this point in the history
…orkflows

build: [INTER-166] use shared workflows
  • Loading branch information
TheUnderScorer authored Oct 30, 2023
2 parents 4551fef + 9bca8d2 commit 48934cc
Show file tree
Hide file tree
Showing 91 changed files with 2,345 additions and 61,698 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
},
ecmaVersion: 2020,
sourceType: 'module',
},
},
plugins: ['@typescript-eslint', 'prettier'],
ignorePatterns: ['build/*'],
rules: {
Expand All @@ -27,4 +27,4 @@ module.exports = {
'@typescript-eslint/no-unused-vars': ['error'],
curly: [2, 'all'],
},
}
}
11 changes: 11 additions & 0 deletions .github/workflows/analyze-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Analyze Commit Messages
on:
pull_request:

permissions:
pull-requests: write
contents: write
jobs:
analyze-commits:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/analyze-commits.yml@v1
42 changes: 0 additions & 42 deletions .github/workflows/build.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: ci
on:
push:
branches-ignore:
- main
paths-ignore:
- '**.md'
- 'cloudformation/*.yml'

jobs:
build-and-check:
name: Build project and run CI checks
uses: fingerprintjs/dx-team-toolkit/.github/workflows/build-typescript-project.yml@v1
with:
nodeVersion: 16
36 changes: 6 additions & 30 deletions .github/workflows/coverage-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,16 @@ name: Check coverage for PR

on:
pull_request:
paths-ignore:
- '**.md'
- 'cloudformation/*.yml'

jobs:
run-tests-check-coverage:
runs-on: ubuntu-20.04
name: Run tests & check coverage
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v3

- name: Install node
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'

- name: Jest coverage comment
id: coverage
uses: ArtiomTr/jest-coverage-report-action@df2b025553c31d68f84be6337843e277e2576844
with:
package-manager: yarn
output: report-markdown
- run: yarn test
- name: Read coverage text report
uses: fingerprintjs/action-coverage-report-md@v1
id: coverage-md
with:
srcBasePath: './src'
- uses: marocchino/sticky-pull-request-comment@adca94abcaf73c10466a71cc83ae561fd66d1a56
with:
message: |
${{ steps.coverage.outputs.report }}
<details>
<summary>Show full coverage report</summary>
${{ steps.coverage-md.outputs.markdownReport }}
</details>
uses: fingerprintjs/dx-team-toolkit/.github/workflows/coverage-diff.yml@v1
with:
nodeVersion: 16
21 changes: 21 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Generate docs and coverage report

on:
push:
paths-ignore:
- '**.md'
- 'cloudformation/*.yml'
branches:
- main


jobs:
generate-docs-and-coverage:
name: Generate docs and coverage report
uses: fingerprintjs/dx-team-toolkit/.github/workflows/docs-and-coverage.yml@v1
with:
skip-docs-step: true
nodeVersion: 16
prepare-gh-pages-commands: |
mv coverage/lcov-report ./gh-pages/coverage
3 changes: 3 additions & 0 deletions .github/workflows/deploy_test_branch.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Deploy test branch
on:
pull_request:
paths-ignore:
- '**.md'
- 'cloudformation/*.yml'

jobs:
deploy-test-branch:
Expand Down
133 changes: 12 additions & 121 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,124 +1,15 @@
name: Release

name: release
on:
workflow_dispatch:
inputs:
version_bump:
description: 'A type of version bump'
default: 'patch'
required: true
type: choice
options:
- major
- minor
- patch
push:
branches:
- main
- test

jobs:
release:
name: Release CloudFront integration distribution
runs-on: ubuntu-20.04

permissions:
contents: write
pull-requests: write

if: github.ref == 'refs/heads/develop'

steps:
- name: Checkout develop branch
uses: actions/checkout@v3
with:
ref: develop
fetch-depth: 0

- name: Install node.js
uses: actions/setup-node@v3
with:
node-version-file: '.node-version'

- name: Set git settings
uses: fregante/setup-git-user@77c1b5542f14ab6db4b8462d6857e31deb988b09

## Build Lambda@Edge function
- name: Install dependencies
run: yarn install

- name: Lint
run: yarn lint

- name: Run tests
run: yarn test

- name: Disable version tags
run: yarn config set version-git-tag false

- name: Bump version
run: yarn version --${{ github.event.inputs.version_bump }}

- name: Build lambda function
run: yarn build

- name: Run type check
run: yarn test:dts

- name: Get new version of lambda@edge
id: version_edge
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8
with:
path: 'package.json'
prop_path: 'version'

## Build Mgmt-lambda function
- name: Install dependencies
working-directory: ./mgmt-lambda
run: yarn install

- name: Lint
working-directory: ./mgmt-lambda
run: yarn lint

- name: Bump version
working-directory: ./mgmt-lambda
run: yarn version --${{ github.event.inputs.version_bump }}

- name: Build lambda function
working-directory: ./mgmt-lambda
run: yarn build

- name: Get new version of mgmt-lambda
id: version_mgmt
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8
with:
path: 'mgmt-lambda/package.json'
prop_path: 'version'

- name: Commit and push new version of lambda
run: |
git commit package.json dist/ -m "build: new lambda@edge function v${{steps.version_edge.outputs.prop}}"
git commit mgmt-lambda/package.json mgmt-lambda/dist/ -m "build: new mgmt-lambda function v${{steps.version_mgmt.outputs.prop}}"
git push "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git tag -a "v${{steps.version_edge.outputs.prop}}" -m "v${{steps.version_edge.outputs.prop}}"
git push --tags "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
## Prepare a release

- name: Create a Github release
uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e
with:
tag: v${{steps.version_edge.outputs.prop}}
name: Release ${{steps.version_edge.outputs.prop}}
generateReleaseNotes: true

- name: Create Pull Request from develop to main
id: create_pr
uses: devops-infra/action-pull-request@e66e2ba93519dc63b9884a26e620e2fd0cffab2c
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
source_branch: develop
target_branch: main
title: New version of scripts v${{ steps.version_edge.outputs.prop }}
body: New version of scripts v${{ steps.version_edge.outputs.prop }}

- name: Check PR outputs
if: ${{ steps.create_pr.outputs.url }}
run: echo "Pull Request URL - ${{ steps.create_pr.outputs.url }}"
build-and-release:
name: 'Build project, run CI checks and publish new release'
uses: fingerprintjs/dx-team-toolkit/.github/workflows/release-typescript-project.yml@v1
with:
nodeVersion: 16
secrets:
GH_RELEASE_TOKEN: ${{ secrets.GH_RELEASE_TOKEN }}
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx commitlint --edit $1
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
15 changes: 15 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
. "$(dirname "$0")/_/husky.sh"

containsref() { if [[ $2 =~ $1 ]]; then echo 1; else echo 0; fi }

push_command=$(ps -ocommand= -p $PPID | cut -d' ' -f 4)
protected_branch='main'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
is_push_to_main_origin=$(containsref '[email protected]:/?fingerprintjs/' "$push_command")

# Block pushes only to protected branch in main repository
if [ $is_push_to_main_origin = 1 ] && [ "$protected_branch" = "$current_branch" ]; then
echo "You are on the $protected_branch branch, push blocked."
exit 1 # push will not execute
fi
Loading

0 comments on commit 48934cc

Please sign in to comment.