Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
danrowden committed Mar 27, 2024
2 parents dfd8614 + eba510b commit 32974fb
Show file tree
Hide file tree
Showing 1,289 changed files with 65,546 additions and 10,711 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: true,
ignorePatterns: ['node_modules', 'dist', 'templates', '**/node_modules'],
ignorePatterns: ['node_modules', 'dist', 'templates', 'scripts', '**/node_modules'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2019,
Expand Down
12 changes: 6 additions & 6 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@

# Actions common lib folder

actions-shared/ @segmentio/build-experience-team
actions-shared/ @segmentio/build-experience-team @segmentio/strategic-connections-team

# AJV utils

ajv-human-errors/ @segmentio/build-experience-team
ajv-human-errors/ @segmentio/build-experience-team @segmentio/strategic-connections-team

# Browser destinations

browser-destinations/ @segmentio/libraries-web-team @segmentio/strategic-connections-team @segmentio/build-experience-team

# CLI private libs

cli-internal/ @segmentio/build-experience-team
cli-internal/ @segmentio/build-experience-team @segmentio/strategic-connections-team

# CLI binary

cli/ @segmentio/build-experience-team
cli/ @segmentio/build-experience-team @segmentio/strategic-connections-team

# Core actions runtime

core/ @segmentio/build-experience-team
core/ @segmentio/build-experience-team @segmentio/strategic-connections-team

# Destination definitions and their actions

destination-actions/ @segmentio/strategic-connections-team @segmentio/build-experience-team

# Utilities for event payload validation against an action's subscription AST.

destination-subscriptions/ @segmentio/build-experience-team
destination-subscriptions/ @segmentio/build-experience-team @segmentio/strategic-connections-team
185 changes: 124 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,116 +7,178 @@ on:
pull_request:

jobs:
test-and-build:
test:
name: Unit tests
runs-on: ubuntu-20.04

timeout-minutes: 30

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v2
# See nx recipe: https://nx.dev/recipes/ci/monorepo-ci-github-actions
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0 # nx recipe

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use Github Personal Access Token
run: git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf ssh://[email protected]/

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
- uses: nrwl/nx-set-shas@v3 # nx recipe

- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Build (Affected)
run: NODE_ENV=production yarn nx affected -t build --parallel=3 # nx recipe

- name: Test (Affected)
run: yarn nx affected -t test --parallel=3 # nx recipe

lint:
name: Lint
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
persist-credentials: false
fetch-depth: 0 # nx recipe

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn

- name: Use Github Personal Access Token
run: git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf ssh://[email protected]/

- uses: nrwl/nx-set-shas@v3 # nx recipe

- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Build
run: NODE_ENV=production yarn build
- name: Build # TODO: This monorepo should be refactored so packages can be linted invidually. "affected" will not work ATM.
run: NODE_ENV=production yarn build # nx recipe

- name: Lint
env:
NODE_OPTIONS: '--max-old-space-size=4096'
run: yarn lint

- name: Validate
run: yarn validate
validate:
name: Validate
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
matrix:
node-version: [18.x]

- name: Test
run: yarn test
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0 # nx recipe

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn

- name: Use Github Personal Access Token
run: git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf ssh://[email protected]/

- uses: nrwl/nx-set-shas@v3 # nx recipe

- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Assert yarn.lock is up-to-date
run: bash scripts/assert-lockfile-updated.sh

- name: Build # TODO: This monorepo should be refactored so packages can be linted invidually. "affected" will not work ATM.
run: NODE_ENV=production yarn build # nx recipe

- name: Validate Definitions
run: yarn validate

- name: destination-subscriptions size
- name: Destination Subscription Size
run: |
if $(lerna changed | grep -q destination-subscriptions); then
yarn subscriptions size
fi
# browser-tests-destination:
# # env: # Disable saucelabs - we blew through our quota.
# # SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
# # SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
- name: Assert generated types are up-to-date
run: bash scripts/assert-types-updated.sh

# runs-on: ubuntu-20.04

# timeout-minutes: 20

# strategy:
# matrix:
# node-version: [18.x]
browser-destination-bundle-qa:
name: Browser Destination Bundle QA
# env: # Disable saucelabs - we blew through our quota.
# SAUCE_USERNAME: ${{secrets.SAUCE_USERNAME}}
# SAUCE_ACCESS_KEY: ${{secrets.SAUCE_ACCESS_KEY}}
runs-on: ubuntu-20.04
timeout-minutes: 20
strategy:
matrix:
node-version: [18.x]

# steps:
# - uses: actions/checkout@master
steps:
- uses: actions/checkout@v3
with:
persist-credentials: false

# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v2
# with:
# node-version: ${{ matrix.node-version }}
# registry-url: 'https://registry.npmjs.org'
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org'
cache: yarn

# - name: Get yarn cache directory path
# id: yarn-cache-dir-path
# run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Use Github Personal Access Token
run: git config --global url."https://${{ secrets.GH_PAT }}@github.com/".insteadOf ssh://[email protected]/

# - uses: actions/cache@v2
# id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
# with:
# path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
# key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
# restore-keys: |
# ${{ runner.os }}-yarn-
- name: Install Dependencies
run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Install Dependencies
# run: yarn install --frozen-lockfile
# env:
# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build
run: NODE_ENV=production yarn build:browser-bundles

# - name: Build
# run: NODE_ENV=production yarn build:browser-destinations && yarn browser build-web
- name: Size Limit
run: yarn browser size

# - name: Run Saucelabs Tests
# working-directory: packages/browser-destinations-integration-tests
# shell: bash
# run: |
# yarn start-destination-server &
# yarn test:sauce
# - name: Run Saucelabs Tests
# working-directory: packages/browser-destinations-integration-tests
# shell: bash
# run: |
# yarn start-destination-server &
# yarn test:sauce

browser-tests-core:
name: 'Browser tests: actions-core'
runs-on: ubuntu-20.04

timeout-minutes: 10
Expand Down Expand Up @@ -164,6 +226,7 @@ jobs:
run: yarn test-browser

snyk:
name: Snyk
runs-on: ubuntu-20.04

timeout-minutes: 5
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/label-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# This workflow labels PRs based on the files that were changed. It uses a custom script to this
# instead of actions/labeler as few of the tags are more than just file changes.

name: Label PRs
on:
pull_request_target:
types: [opened, synchronize, reopened]

jobs:
pr-labeler:
runs-on: ubuntu-20.04
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Compute Labels
id: compute-labels
uses: actions/github-script@v7
with:
# Required for the script to access team membership information.
# Scope: members:read and contentes:read permission on the organization.
github-token: ${{ secrets.GH_PAT_MEMBER_AND_PULL_REQUEST_READONLY }}
script: |
const script = require('./scripts/compute-labels.js')
await script({github, context, core})
- name: Apply Labels
uses: actions/github-script@v7
env:
labelsToAdd: '${{ steps.compute-labels.outputs.add }}'
labelsToRemove: '${{ steps.compute-labels.outputs.remove }}'
with:
script: |
const { labelsToAdd, labelsToRemove } = process.env
if(labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
issue_number: context.payload.pull_request.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: labelsToAdd.split(',')
});
}
if(labelsToRemove.length > 0) {
const requests = labelsToRemove.split(',').map(label => {
return github.rest.issues.removeLabel({
issue_number: context.payload.pull_request.number,
name: label,
owner: context.repo.owner,
repo: context.repo.repo
});
});
await Promise.all(requests);
}
32 changes: 32 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,35 @@ jobs:
- name: Publish
run: |
yarn lerna publish from-git --yes --allowBranch=main --loglevel=verbose --dist-tag latest
- name: Generate and Push Release Tag
id: push-release-tag
run: |
git config user.name ${{ github.actor }}
git config user.email ${{ github.actor }}@users.noreply.github.com
commit=${{ github.sha }}
if ! n=$(git rev-list --count $commit~ --grep "Publish" --since="00:00"); then
echo 'failed to calculate tag'
exit 1
fi
case "$n" in
0) suffix="" ;; # first commit of the day gets no suffix
*) suffix=".$n" ;; # subsequent commits get a suffix, starting with .1
esac
tag=$(printf release-$(date '+%Y-%m-%d%%s') $suffix)
git tag -a $tag -m "Release $tag"
git push origin $tag
echo "release-tag=$tag" >> $GITHUB_OUTPUT
- name: Create Github Release
id: create-github-release
uses: actions/github-script@v7
env:
RELEASE_TAG: ${{ steps.push-release-tag.outputs.release-tag }}
with:
script: |
const script = require('./scripts/create-github-release.js')
await script({github, context, core, exec})
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ node_modules
dist
.DS_Store
*.log
*.tsbuildinfo
*.tsbuildinfo*
.eslintcache
package-lock.json
.env
Expand Down
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
packages/cli-internal
Loading

0 comments on commit 32974fb

Please sign in to comment.