Skip to content

Commit

Permalink
fix: small cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
simllll committed Feb 20, 2023
1 parent 8a5ded1 commit be00e45
Show file tree
Hide file tree
Showing 8 changed files with 15,058 additions and 18 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/pack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ jobs:
run: npm run build
- name: Pack
run: npm run pack
- name: Check packed JS changes
id: packedJsStatus
run: echo ::set-output name=changes::$(git status ${{ env.PACKED_JS_PATH }} --porcelain)
- name: Commit new build output
uses: EndBug/[email protected]
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
HUSKY_SKIP_INSTALL: true

jobs:
eslint:
lint:
name: Code quality
runs-on: ubuntu-latest
steps:
Expand All @@ -26,8 +26,8 @@ jobs:
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install packages
run: npm install
- name: ESLint
run: npm run eslint
- name: Lint
run: npm run lint

tests:
name: Unit tests
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Contributions are encouraged! Fork this repo and open a pull request.
### Commands

| command | description |
| -------- | --------------------------------------------------------------------------------------------------------- |
|----------| --------------------------------------------------------------------------------------------------------- |
| `test` | Run the unit tests |
| `eslint` | Run eslint on all applicable files |
| `lint` | Run eslint on all applicable files |
| `format` | Run prettier on all applicable files |
| `build` | build the dist file. You are required to run this locally in order to build the dist before opening a PR. |

Expand Down
15,032 changes: 15,032 additions & 0 deletions dist/licenses.txt

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"test": "jest --passWithNoTests --coverage",
"local": "babel-node src/cli",
"format": "prettier --write src/*.js src/**/*.js *.js",
"eslint": "eslint --ext .ts src/ test/",
"lint": "eslint --ext .ts src/ test/",
"pre-commit": "lint-staged"
},
"type": "module",
Expand Down
5 changes: 5 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ export async function setTemporarLvocFilesAsBase(
);
}),
);
return files.length;
}

export async function uploadTemporaryLvocFiles(
Expand All @@ -209,6 +210,8 @@ export async function uploadTemporaryLvocFiles(
);
}),
);

return lcovFiles.length;
}

export async function generateReport(
Expand Down Expand Up @@ -258,4 +261,6 @@ export async function generateReport(
monorepoBasePath.split("/")[1]
} -->`,
);

return lcovArrayForMonorepo.length;
}
21 changes: 12 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ try {
throw new Error(`failed parsing s3 config json: ${err}`);
}

// todo debug
// eslint-disable-next-line no-console
console.log("s3ConfigParsed", s3ConfigParsed);

const s3Client = s3ConfigParsed && new S3Client(s3ConfigParsed);

if (!monorepoBasePath) {
Expand All @@ -45,14 +41,16 @@ try {
}

// upload new lcov base files to storage
await setTemporarLvocFilesAsBase(
const cnt = await setTemporarLvocFilesAsBase(
s3Client,
s3ConfigParsed.Bucket,
context.repo,
context.payload.pull_request.number,
monorepoBasePath,
base,
);
// eslint-disable-next-line no-console
console.info(`updated ${cnt} lcov files as new base`);
} else {
// generate diff report
if (!context.payload.pull_request?.number) {
Expand All @@ -61,7 +59,7 @@ try {

const client = getOctokit(token);

await generateReport(
const cntReport = await generateReport(
client,
s3Client,
s3ConfigParsed?.Bucket,
Expand All @@ -71,19 +69,24 @@ try {
base,
);

// eslint-disable-next-line no-console
console.info(`generated report for ${cntReport} lcov files`);

if (s3Client && s3ConfigParsed) {
await uploadTemporaryLvocFiles(
const cntUpload = await uploadTemporaryLvocFiles(
s3Client,
s3ConfigParsed.Bucket,
context.repo,
context.payload.pull_request.number,
monorepoBasePath,
base,
);

// eslint-disable-next-line no-console
console.info(`uploaded ${cntUpload} temporary lcov files`);
}
}
} catch (err) {
// eslint-disable-next-line no-console
console.log(err);
console.error(err);
setFailed(err instanceof Error ? err.message : JSON.stringify(err));
}

0 comments on commit be00e45

Please sign in to comment.