-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing External PR (Github App) (#1064)
* Initial testing setup for external prs * updates to load priv key from base64 * attempt to setup local supabase * fix * more supabase testing * fix * update ignore * fix * Add inline docs * additional testing for external-prs lib * add CODEOWNERS
- Loading branch information
Showing
13 changed files
with
309 additions
and
112 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Any changes to .github should trigger require one of the ops team to review | ||
.github/* @opensource-observer/ops | ||
ops/* @opensource-observer/ops |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
cd "$1" | ||
|
||
pnpm supabase start | ||
export $(pnpm supabase status -o env | xargs) | ||
echo "SUPABASE_SERVICE_KEY=$SERVICE_ROLE_KEY" >> $GITHUB_ENV | ||
echo "SUPABASE_JWT_SECRET=$JWT_SECRET" >> $GITHUB_ENV | ||
echo "NEXT_PUBLIC_SUPABASE_URL=$API_URL" >> $GITHUB_ENV | ||
echo "NEXT_PUBLIC_SUPABASE_ANON_KEY=$ANON_KEY" >> $GITHUB_ENV |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,3 +59,7 @@ dbt_packages/ | |
|
||
# Python | ||
*.pyc | ||
|
||
supabase/.temp/ | ||
**/supabase/.temp/ | ||
*/**/supabase/.temp/ |
4 changes: 4 additions & 0 deletions
4
apps/frontend/supabase/migrations/20240209235914_hasura_claim.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": ["../../.eslintrc.js"], | ||
"root": false, | ||
"parserOptions": { | ||
"project": ["./ops/external-prs/tsconfig.json"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# External PRs | ||
|
||
A Github App that allows us to accept external PRs by enabling PR checks by an | ||
out of band process. We need this because some of the checks require _some_ form | ||
of authentication. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "@opensource-observer/ops-external-prs", | ||
"version": "0.0.1", | ||
"description": "External PRs github app for OSO", | ||
"author": "Kariba Labs", | ||
"license": "Apache-2.0", | ||
"private": true, | ||
"main": "./dist/src/index.js", | ||
"types": "./dist/src/index.d.ts", | ||
"type": "module", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/opensource-observer/oso.git" | ||
}, | ||
"engines": { | ||
"node": ">=20" | ||
}, | ||
"scripts": { | ||
"build": "tsc", | ||
"lint": "tsc --noEmit && pnpm lint:eslint && pnpm lint:prettier", | ||
"lint:eslint": "eslint --ignore-path ../../.gitignore --max-warnings 0 .", | ||
"lint:prettier": "prettier --ignore-path ../../.gitignore --log-level warn --check **/*.{js,jsx,ts,tsx,sol,md,json}" | ||
}, | ||
"keywords": [], | ||
"devDependencies": { | ||
"@types/node": "^20.11.17", | ||
"dotenv": "^16.4.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.3.3" | ||
}, | ||
"dependencies": { | ||
"octokit": "^3.1.0", | ||
"yaml": "^2.3.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { App } from "octokit"; | ||
import dotenv from "dotenv"; | ||
|
||
dotenv.config(); | ||
|
||
async function main() { | ||
const APP_TO_CHECK = process.env.APP_TO_CHECK; | ||
const SHA_TO_CHECK = process.env.SHA_TO_CHECK; | ||
|
||
const buf = Buffer.from(process.env.APP_PRIVATE_KEY!, "base64"); // Ta-da | ||
|
||
const app = new App({ | ||
appId: process.env.APP_ID!, | ||
privateKey: buf.toString("utf-8"), | ||
}); | ||
|
||
const { data } = await app.octokit.request("/app"); | ||
console.log(`Authenticated as ${data.name}`); | ||
|
||
for await (const { installation } of app.eachInstallation.iterator()) { | ||
for await (const { octokit, repository } of app.eachRepository.iterator({ | ||
installationId: installation.id, | ||
})) { | ||
console.log(repository.name); | ||
if (repository.name !== APP_TO_CHECK) { | ||
continue; | ||
} | ||
const resp = await octokit.request( | ||
"POST /repos/{owner}/{repo}/check-runs", | ||
{ | ||
owner: repository.owner.login, | ||
repo: repository.name, | ||
data: { | ||
name: "test-deployment2", | ||
head_sha: SHA_TO_CHECK, | ||
status: "completed", | ||
conclusion: "success", | ||
output: { | ||
title: "test-deployment2", | ||
summary: "This is some summary", | ||
}, | ||
}, | ||
}, | ||
); | ||
console.log(resp); | ||
} | ||
} | ||
} | ||
|
||
main().catch((e) => { | ||
console.log(e); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"outDir": "dist", | ||
"target": "ES6", | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"declaration": true, | ||
"declarationMap": true, | ||
"esModuleInterop": true, | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"noImplicitAny": true, | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"strictPropertyInitialization": false, | ||
}, | ||
"exclude": ["node_modules"], | ||
"include": ["./src/*.ts", "./src/**/*.ts", "./test"], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.