Skip to content

Commit

Permalink
Merge pull request #9 from n0th1ng-else/test-4
Browse files Browse the repository at this point in the history
  • Loading branch information
n0th1ng-else authored Nov 16, 2021
2 parents b366e1e + 5a77b99 commit 33b1c9f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
31 changes: 25 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# **semantic-release-pr-analyzer**

semantic-release plugin that imitates the behaviour when the team relies on the **_squash and merge_** strategy
on GitHub.

## Install

```bash
Expand Down Expand Up @@ -27,11 +30,11 @@ The plugin can be configured in the [**semantic-release** configuration file](ht

### Options

| Option | Description | Default |
| ---------------------- | ------------------ | -------- |
| `strategy` | analyzing strategy | `github` |
| `commitAnalyzerConfig` | TODO | none |
| `notesGeneratorConfig` | TODO | none |
| Option | Description | Default |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------- |
| `strategy` | analyzing strategy | `github` |
| `commitAnalyzerConfig` | standard commit-analyzer plugin [configuration](https://github.com/semantic-release/commit-analyzer#configuration) | default one for commit-analyzer |
| `notesGeneratorConfig` | standard release-notes-generator plugin [configuration](https://github.com/semantic-release/release-notes-generator#configuration) | default one for release-notes-generator |

## Strategy

Expand All @@ -46,4 +49,20 @@ Always analyzes the pull request title and description as a commit.

### Strict Pull Request strategy (`{strategy: 'strict-pull-request'}`)

The same as the **_Pull Request strategy_**, but it will throw an error if the first commit body is not equal to the pull request description.
The same as the **_Pull Request strategy_**, but it will throw an error if the first commit body is not equal
to the pull request description.

## Environment variables

### env.GITHUB_TOKEN

GitHub token to access your repository. Using the `secrets.GITHUB_TOKEN` value should be enough.

### env.GITHUB_PR_NUMBER

The pull request number. In the context of GitHub actions, it is achievable as `github.event.pull_request.number`

### env.GITHUB_REPOSITORY

Repository path, for example `n0th1ng-else/semantic-release-pr-analyzer`. For GitHub actions workflow it is
set automatically.
21 changes: 21 additions & 0 deletions src/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,5 +416,26 @@ describe("utils", () => {
);
});
});

describe("Environment vars", () => {
it.each([["GITHUB_TOKEN"], ["GITHUB_PR_NUMBER"], ["GITHUB_REPOSITORY"]])(
"throws an error when env.%s is not specified",
(envKey) => {
setEnv();
process.env[envKey] = "";

const strategy = "pull-request";

return getCommit(strategy, []).then(
() => {
throw new Error("Should not be there");
},
(err) => {
expect(err.message).toBe(`${envKey} is not defined`);
}
);
}
);
});
});
});

0 comments on commit 33b1c9f

Please sign in to comment.