Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Make the action faster by parallelizing promises #42

Merged
merged 3 commits into from
Jan 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# When you reference an action with `uses: ` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# For our project, we generate this file through a building process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
# If index.js was different from expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/code_scanning.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,16 @@ on:
jobs:
qodana:
runs-on: ubuntu-latest
env:
GRAZIE_PLUGIN: https://plugins.jetbrains.com/plugin/download?rel=true&updateId=152587
steps:
- uses: actions/checkout@v2
- run: |
curl -L -o grazie-pro.zip "$GRAZIE_PLUGIN" && unzip grazie-pro.zip
mv grazie-pro ${{ runner.temp }}/grazie-pro && rm -f grazie-pro.zip
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v4.2.2
with:
linter: jetbrains/qodana-js
additional-volumes: |
${{ runner.temp }}/grazie-pro:/opt/idea/plugins/grazie-pro
9 changes: 0 additions & 9 deletions .github/workflows/example.yml

This file was deleted.

9 changes: 6 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ on: # rebuild any PRs and main branch changes

jobs:
build: # make sure build/ci work properly
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
steps:
- uses: actions/checkout@v2
- run: |
npm install
- run: |
npm run all
npm test

test-ubuntu: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<!-- toc -->

- [Qodana Scan](#qodana-scan)
- Qodana Scan
- [Usage](#usage)
- [Configuration](#configuration)
- [Issue Tracker](#issue-tracker)
Expand All @@ -21,7 +21,7 @@

## Usage

You can run Qodana with GitHub Actions using [Qodana Scan](https://github.com/marketplace/actions/qodana-scan).
You can run Qodana with GitHub Actions using [Qodana Scan](https://github.com/marketplace/actions/qodana-scan).
To do it, add `.github/workflows/code_scanning.yml` to your repository with the following contents:

```yaml
Expand All @@ -45,7 +45,7 @@ jobs:
```
We recommend that you have a separate workflow file for Qodana because [different jobs run in parallel](https://help.github.com/en/actions/getting-started-with-github-actions/core-concepts-for-github-actions#job).

Using this workflow, Qodana will run on the main branch, release branches, and on the pull requests coming to your
Using this workflow, Qodana will run on the main branch, release branches, and on the pull requests coming to your
repository. Inspection results will be available in the GitHub UI.

### Get a Qodana badge
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:

### GitHub Pages

If you want to study [Qodana reports](https://www.jetbrains.com/help/qodana/html-report.html) directly on GitHub, you
If you want to study [Qodana reports](https://www.jetbrains.com/help/qodana/html-report.html) directly on GitHub, you
can host it on your repository [GitHub Pages](https://docs.github.com/en/pages) using this example workflow:

```yaml
Expand All @@ -107,7 +107,7 @@ can host it on your repository [GitHub Pages](https://docs.github.com/en/pages)

### Pull request quality gate

You can enforce GitHub to block the merge of pull requests if the Qodana quality gate has failed. To do it, create a
You can enforce GitHub to block the merge of pull requests if the Qodana quality gate has failed. To do it, create a
branch protection rule as described below:

1. Create new or open an existing GitHub workflow with the Qodana Action specified.
Expand Down Expand Up @@ -179,7 +179,7 @@ This repository contains source code for Qodana GitHub Action and is licensed un

View [license information](https://www.jetbrains.com/legal/?fromFooter#licensing) for the Qodana Community images.

Qodana Docker images may contain other software which is subject to other licenses, for example, Bash relating to the base distribution or with any direct or indirect dependencies of the primary software).
Qodana Docker images may contain other software which is subject to other licenses, for example, Bash relating to the base distribution or with any direct or indirect dependencies of the primary software.

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

Expand Down
28 changes: 14 additions & 14 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import {expect, test} from '@jest/globals'
import {Output, parseSarif} from '../src/annotations'
import {Inputs} from '../src/context'
import {getQodanaRunArgs} from '../src/docker'
import {
QODANA_CHECK_NAME,
QODANA_HELP_STRING,
validateContext
} from '../src/utils'
import {dockerPull, getQodanaRunArgs} from '../src/docker'
import {QODANA_CHECK_NAME, QODANA_HELP_STRING} from '../src/utils'

function outputEmptyFixture(): Output {
return {
Expand Down Expand Up @@ -85,19 +81,22 @@ function inputsDefaultFixture(): Inputs {
}

function defaultDockerRunCommandFixture(): string[] {
return [
let args = [
'run',
'--rm',
'-e',
'CI=GITHUB',
'QODANA_ENV=github',
'-v',
'${{ runner.temp }}/qodana-caches:/data/cache',
'-v',
'${{ github.workspace }}:/data/project',
'-v',
'${{ runner.temp }}/qodana-results:/data/results',
'-u',
`${process.getuid()}:${process.getgid()}`,
'${{ runner.temp }}/qodana-results:/data/results'
]
if (process.platform !== 'win32') {
args.push('-u', `${process.getuid()}:${process.getgid()}` ?? '1001:1001')
}
args.push(
'-v',
'/tmp/project:/data/project',
'-e',
Expand All @@ -110,7 +109,8 @@ function defaultDockerRunCommandFixture(): string[] {
'10',
'-n',
'qodana.recommended'
]
)
return args
}

test('docker run command args', () => {
Expand All @@ -131,8 +131,8 @@ test('test sarif with no problems to output annotations', () => {
expect(result).toEqual(output)
})

test('input validation', () => {
test('fail pulling unsuppored linter', async () => {
const inputs = inputsDefaultFixture()
inputs.linter = 'jetbrains/qodana-clone-finder'
expect(() => validateContext(inputs)).toThrow()
await expect(dockerPull(inputs.linter)).rejects.toThrow()
})
121 changes: 66 additions & 55 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.