Skip to content

Commit

Permalink
feat: Update test runners and CI/CD scripts (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-mparticle authored Jul 11, 2024
1 parent 054d85d commit cc24939
Show file tree
Hide file tree
Showing 17 changed files with 13,376 additions and 3,952 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Web Kit Build & Test

on: pull_request

jobs:
build-and-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: NPM install
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Run NPM CI
run: npm ci

- name: Build Files
run: npm run build

- name: Run Core tests
run: npm run test

- name: Archive npm failure logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs
153 changes: 153 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Release Kit

on:
workflow_dispatch:
inputs:
dryRun:
description: 'Do a dry run to preview instead of a real release [true/false]'
required: true
default: 'true'

jobs:
# Kit release is done from master branch.
confirm-public-repo-master-branch:
name: 'Confirm release is run from public/master branch'
uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@stable

build-and-test:
name: Build and Test
runs-on: ubuntu-latest
needs: confirm-public-repo-master-branch
steps:
- name: Checkout
uses: actions/checkout@v4

- name: NPM install
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Run NPM CI
run: npm ci

- name: Build Files
run: npm run build

- name: Run Core tests
run: npm run test

- name: Archive npm failure logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs

create-release-branch:
name: Create release branch
runs-on: ubuntu-latest
needs:
- build-and-test
- confirm-public-repo-master-branch
steps:
- name: Checkout development branch
uses: actions/checkout@v4
with:
# TODO: Update this with the name of your repository
repository: mparticle-integrations/mparticle-javascript-integration-example
ref: development

- name: Create and push release branch
run: |
git checkout -b release/${{ github.run_number }}
git push origin release/${{ github.run_number }}
release:
name: Perform Release
runs-on: ubuntu-latest
needs:
- build-and-test
- create-release-branch
- confirm-public-repo-master-branch
env:
GITHUB_TOKEN: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}
GIT_AUTHOR_NAME: mparticle-automation
GIT_AUTHOR_EMAIL: developers@mparticle.com
GIT_COMMITTER_NAME: mparticle-automation
GIT_COMMITTER_EMAIL: developers@mparticle.com
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

steps:
- name: Checkout public master branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true

- name: Merge release branch into master branch
run: |
git pull origin release/${{ github.run_number }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x

- name: Install dependencies
run: npm ci

- name: Release --dry-run
if: ${{ github.event.inputs.dryRun == 'true'}}
run: |
npx semantic-release --dry-run
- name: Release
if: ${{ github.event.inputs.dryRun == 'false'}}
run: |
npx semantic-release
- name: Archive npm failure logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: npm-logs
path: ~/.npm/_logs

- name: Push automated release commits to release branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push origin HEAD:release/${{ github.run_number }}
sync-repository:
name: Sync repositories
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout master branch
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.repository }}
token: ${{ secrets.MP_INTEGRATIONS_SEMANTIC_RELEASE_BOT }}
ref: master

- name: Merge release branch into master branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git pull origin release/${{ github.run_number }}
- name: Push release commits to master and development branches
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push origin HEAD:development
git push origin HEAD:master
- name: Delete release branch
if: ${{ github.event.inputs.dryRun == 'false' }}
run: |
git push --delete origin release/${{ github.run_number }}
20 changes: 20 additions & 0 deletions .github/workflows/reusable-workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Reusable Workflows

on:
pull_request:

jobs:
pr-branch-check-name:
name: Check PR for semantic branch name
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-check-name.yml@stable
pr-title-check:
name: Check PR for semantic title
uses: mParticle/mparticle-workflows/.github/workflows/pr-title-check.yml@stable
pr-branch-target-gitflow:
name: Check PR for semantic target branch
uses: mParticle/mparticle-workflows/.github/workflows/pr-branch-target-gitflow.yml@stable
security-lint-checks:
name: Security Lint Checks
uses: mparticle/mparticle-workflows/.github/workflows/security-checks.yml@stable
with:
base_branch: 'development'
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.13.1
Loading

0 comments on commit cc24939

Please sign in to comment.