Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
BobrImperator committed Sep 9, 2024
0 parents commit dedcb2f
Show file tree
Hide file tree
Showing 72 changed files with 16,043 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CI

on:
push:
branches:
- master
pull_request: {}

jobs:
test-ember-memory-leaks:
name: Test Emberfest2024
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node_version: 20
- uses: pnpm/action-setup@v4
- uses: actions/cache@v4
with:
path: "**/node_modules"
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: install dependencies
run: pnpm install --frozen-lockfile

- name: tests
run: pnpm test:memory-leak-ember
90 changes: 90 additions & 0 deletions .github/workflows/plan-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Release Plan Review
on:
push:
branches:
- main
- master
pull_request_target: # This workflow has permissions on the repo, do NOT run code from PRs in this workflow. See https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
types:
- labeled
- unlabeled

concurrency:
group: plan-release # only the latest one of these should ever be running
cancel-in-progress: true

jobs:
check-plan:
name: "Check Release Plan"
runs-on: ubuntu-latest
outputs:
command: ${{ steps.check-release.outputs.command }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: 'master'
# This will only cause the `check-plan` job to have a "command" of `release`
# when the .release-plan.json file was changed on the last commit.
- id: check-release
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT

prepare_release_notes:
name: Prepare Release Notes
runs-on: ubuntu-latest
timeout-minutes: 5
needs: check-plan
permissions:
contents: write
issues: read
pull-requests: write
outputs:
explanation: ${{ steps.explanation.outputs.text }}
# only run on push event if plan wasn't updated (don't create a release plan when we're releasing)
# only run on labeled event if the PR has already been merged
if: (github.event_name == 'push' && needs.check-plan.outputs.command != 'release') || (github.event_name == 'pull_request_target' && github.event.pull_request.merged == true)

steps:
- uses: actions/checkout@v4
# We need to download lots of history so that
# github-changelog can discover what's changed since the last release
with:
fetch-depth: 0
ref: 'master'
- uses: actions/setup-node@v4
with:
node_version: 20
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- name: "Generate Explanation and Prep Changelogs"
id: explanation
run: |
set +e
pnpm release-plan prepare 2> >(tee -a release-plan-stderr.txt >&2)
if [ $? -ne 0 ]; then
echo 'text<<EOF' >> $GITHUB_OUTPUT
cat release-plan-stderr.txt >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
else
echo 'text<<EOF' >> $GITHUB_OUTPUT
jq .description .release-plan.json -r >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
rm release-plan-stderr.txt
fi
env:
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}

- uses: peter-evans/create-pull-request@v6
with:
commit-message: "Prepare Release using 'release-plan'"
labels: "internal"
branch: release-preview
title: Prepare Release
body: |
This PR is a preview of the release that [release-plan](https://github.com/embroider-build/release-plan) has prepared. To release you should just merge this PR 👍
-----------------------------------------
${{ steps.explanation.outputs.text }}
59 changes: 59 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# For every push to the master branch, this checks if the release-plan was
# updated and if it was it will publish stable npm packages based on the
# release plan

name: Publish Stable

on:
workflow_dispatch:
push:
branches:
- master

concurrency:
group: publish-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
check-plan:
name: "Check Release Plan"
runs-on: ubuntu-latest
outputs:
command: ${{ steps.check-release.outputs.command }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: 'master'
# This will only cause the `check-plan` job to have a result of `success`
# when the .release-plan.json file was changed on the last commit. This
# plus the fact that this action only runs on main will be enough of a guard
- id: check-release
run: if git diff --name-only HEAD HEAD~1 | grep -w -q ".release-plan.json"; then echo "command=release"; fi >> $GITHUB_OUTPUT

publish:
name: "NPM Publish"
runs-on: ubuntu-latest
needs: check-plan
if: needs.check-plan.outputs.command == 'release'
permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node_version: 20
- uses: pnpm/action-setup@v4
- run: pnpm install --frozen-lockfile
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: npm publish
run: pnpm release-plan publish
env:
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "root",
"private": true,
"version": "1.0.0",
"description": "",
"scripts": {
"test:memory-leak-ember": "pnpm -F ember-test-app start:memory-leak-detector & pid=$!; pnpm -F ember-test-app test; wait $pid",
"test:memory-leak-ember-server": "pnpm -F ember-test-app start:memory-leak-detector & pid=$!; pnpm -F ember-test-app test --server; wait $pid"
},
"keywords": [],
"author": "",
"license": "ISC",
"engines": {
"node": "20.16.0"
},
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"intersection-observer-admin": "0.3.2"
}
}
}
19 changes: 19 additions & 0 deletions packages/memory-leak-detector/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const CDP = require('chrome-remote-interface');

async function connect() {
let client;
try {
client = await CDP({ port: 9222, host: "127.0.0.1" });
console.log('Connected to Chrome!');
// Perform operations using the client here
} catch (err) {
console.error('Error connecting to Chrome:', err);
} finally {
if (client) {
await client.close();
}
}
}

connect();

49 changes: 49 additions & 0 deletions packages/memory-leak-detector/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
export async function detectMemoryLeak(by, value, assertions) {
let response = await fetch(`http://localhost:3000/detect_memory_leak`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
identifier: {
by,
value,
},
assertions,
}),
});
let json = await response.json();

return json.results;
}

export async function detectLeakingClasses(by, value) {
let response = await fetch(`http://localhost:3000/detect_leaking_classes`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
identifier: {
by,
value,
},
}),
});
let json = await response.json();

return json.results;
}

export async function close() {
let response = await fetch(`http://localhost:3000/close`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: null,
});
let json = await response.json();

return json;
}
24 changes: 24 additions & 0 deletions packages/memory-leak-detector/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "memory-leak-detector",
"version": "0.1.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"bin": {
"memory-leak-detector": "./server/index.js"
},
"dependencies": {
"@babel/parser": "^7.12.10",
"ast-types": "^0.14.2",
"chrome-remote-interface": "^0.28.2",
"ember-cli-babel": "^7.22.1",
"ember-cli-htmlbars": "^5.3.1",
"glob": "^7.1.6",
"heapsnapshot": "0.0.6"
}
}
Loading

0 comments on commit dedcb2f

Please sign in to comment.