Skip to content

Commit

Permalink
add PR action (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
baked-dev authored Feb 1, 2023
1 parent 00b8e57 commit f4ca5b1
Show file tree
Hide file tree
Showing 12 changed files with 208 additions and 15 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
on:
pull_request:
types:
- synchronize
- opened

name: PR

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: whop

concurrency:
group: pr-action-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
install:
name: Install node modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install

lint:
name: Lint repository
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install
- name: Run eslint
run: pnpx eslint ./ --max-warnings 0

build:
name: Build packages
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install
- name: Build packages
run: pnpm turbo build

test:
name: Test repository
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install
- name: Build packages
run: pnpm turbo test

5 changes: 4 additions & 1 deletion packages/action/out/290.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ function* generator(getNext) {
}
}
const getCommand = async (strings, vars, results) => {
const parts = [strings.shift()];
const first = strings.shift();
if (!first)
return "";
const parts = [first];
for (const idx in strings) {
const variable = vars[idx];
parts.push(`${typeof variable === "function" ? await variable(results) : variable}`);
Expand Down
10 changes: 7 additions & 3 deletions packages/action/out/587.index.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ var performUpdate = function() {
var teamOwnershipRegex = /^@(.*)\/(.*)$/;
var runAction = function() {
var _ref = type_asyncToGenerator(function() {
var _ref, comment, packageCodeOwners, type, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, packageCodeOwner, _comment_user, _teamOwnershipRegex_exec, org, team_slug, _ref1, state, e, err;
var _ref, comment, packageCodeOwners, type, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, packageCodeOwner, _comment_user, _ref1, org, team_slug, _ref2, state, e, err;
return type_generator(this, function(_state) {
switch(_state.label){
case 0:
Expand Down Expand Up @@ -637,7 +637,11 @@ var runAction = function() {
3,
10
];
_teamOwnershipRegex_exec = _slicedToArray(teamOwnershipRegex.exec(packageCodeOwner), 3), org = _teamOwnershipRegex_exec[1], team_slug = _teamOwnershipRegex_exec[2];
_ref1 = _slicedToArray(teamOwnershipRegex.exec(packageCodeOwner) || [], 3), org = _ref1[1], team_slug = _ref1[2];
if (!org || !team_slug) return [
3,
12
];
_state.label = 5;
case 5:
_state.trys.push([
Expand All @@ -655,7 +659,7 @@ var runAction = function() {
})
];
case 6:
_ref1 = _state.sent(), state = _ref1.data.state;
_ref2 = _state.sent(), state = _ref2.data.state;
if (state !== "active") return [
3,
12
Expand Down
6 changes: 4 additions & 2 deletions packages/action/src/release-pull/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import getCodeOwners from "../util/get-codeowners";

const types = ["patch", "minor", "major"] as const;

type ReleaseTypes = typeof types[number];
type ReleaseTypes = (typeof types)[number];

const getPackageJson = async (ref?: string) => {
const { data: content } = await octo.rest.repos.getContent({
Expand Down Expand Up @@ -111,7 +111,9 @@ const runAction = async () => {
const type = comment.body.slice(1) as ReleaseTypes;
for (const packageCodeOwner of packageCodeOwners) {
if (teamOwnershipRegex.test(packageCodeOwner) && comment.user) {
const [, org, team_slug] = teamOwnershipRegex.exec(packageCodeOwner)!;
const [, org, team_slug] =
teamOwnershipRegex.exec(packageCodeOwner) || [];
if (!org || !team_slug) continue;
try {
const {
data: { state },
Expand Down
2 changes: 1 addition & 1 deletion packages/action/src/util/get-history.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { octo, owner, repo } from "../context";

const gql = ([...strings]: TemplateStringsArray, ...vars: any[]) => {
const gql = ([...strings]: TemplateStringsArray, ...vars: unknown[]) => {
if (!strings.length) return "";
const parts = [strings.shift()];
for (const idx in strings) {
Expand Down
90 changes: 90 additions & 0 deletions packages/create-turbo-module/template/.github/workflows/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
on:
pull_request:
types:
- synchronize
- opened

name: PR

concurrency:
group: pr-action-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
install:
name: Install node modules
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install

lint:
name: Lint repository
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install
- name: Run eslint
run: pnpx eslint ./ --max-warnings 0

build:
name: Build packages
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install
- name: Build packages
run: pnpm turbo build

test:
name: Test repository
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7.13.6
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 16
check-latest: true
cache: pnpm
- name: Install all packages
run: pnpm install
- name: Build packages
run: pnpm turbo test

1 change: 0 additions & 1 deletion packages/turbo-module/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"turbo-module": "dist/index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsup ./src/index.ts --format cjs",
"release": "node dist/index.js publish",
"dev": "pnpm run build --watch"
Expand Down
2 changes: 1 addition & 1 deletion packages/turbo-module/src/util/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type ImportedHandler = () => Promise<{
default: () => any;
default: () => unknown;
}>;

export type CliLayout = {
Expand Down
4 changes: 3 additions & 1 deletion packages/util/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ const getCommand = async (
vars: BashVars[],
results: ResultType
) => {
const parts: string[] = [strings.shift()!];
const first = strings.shift();
if (!first) return "";
const parts: string[] = [first];
for (const idx in strings) {
const variable = vars[idx];
parts.push(
Expand Down
3 changes: 0 additions & 3 deletions packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"description": "Internal shared utils package.",
"private": true,
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
Expand Down
6 changes: 4 additions & 2 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
},
"dev": {
"cache": false
},
"test": {
"dependsOn": ["build"]
}
},
"globalDependencies": ["$VERSION", "$GITHUB_TOKEN", "$INITIAL_COMMIT"]
}
}

0 comments on commit f4ca5b1

Please sign in to comment.