Skip to content

Commit

Permalink
feat(release): dry-run (projen#1363)
Browse files Browse the repository at this point in the history
Co-authored-by: Christopher Rybicki <rybickic@amazon.com>
Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
3 people authored Dec 23, 2021
1 parent 177ef19 commit 47f2be9
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions .mergify.yml

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

3 changes: 3 additions & 0 deletions .projen/tasks.json

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

2 changes: 2 additions & 0 deletions .projenrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ const pythonCompatTask = project.addTask('integ:python-compat', {
});
const integTask = project.addTask('integ');
integTask.spawn(project.buildTask);
integTask.spawn(project.tasks.tryFind('package:python'));
integTask.spawn(pythonCompatTask);
project.tryFindObjectFile('.mergify.yml').addOverride('pull_request_rules.0.conditions.3', 'status-success=integ');

new github.TaskWorkflow(project.github, {
name: 'integ',
Expand Down
8 changes: 8 additions & 0 deletions docs/publisher.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,11 @@ This will create an issue labeled with the `failed-release` label for every indi
For example, if Nuget publishing failed for a specific version, it will create an issue titled *Publishing v1.0.4 to Nuget gallery failed*.

This can be helpful to keep track of failed releases as well as integrate with third-party ticketing systems by querying issues labeled with `failed-release`.

## Dry run

If you wish to completely disable publishing, you can enable the `dryRun` option on
`Publisher` or `publishDryRun` on the project.

This will cause all publishing tasks and jobs to just print the publishing
command but not actually publish.
29 changes: 29 additions & 0 deletions test/release/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,33 @@ test('if publishTasks is disabled, no publish tasks are created', () => {
const files = synthSnapshot(project);
const tasks = files['.projen/tasks.json'].tasks;
expect(Object.keys(tasks).filter(t => t.startsWith('publish:')).length).toBe(0);
});

test('dryRun', () => {
// GIVEN
const project = new TestProject();

const release = new Release(project, {
task: project.buildTask,
versionFile: 'version.json',
branch: 'main',
artifactsDirectory: 'dist',
publishDryRun: true,
});

// WHEN
release.publisher.publishToGo();
release.publisher.publishToMaven();
release.publisher.publishToNpm();
release.publisher.publishToNuget();
release.publisher.publishToPyPi();

// THEN
const files = synthSnapshot(project);
const releaseWorkflow = YAML.parse(files['.github/workflows/release.yml']);
const releaseJobs = Object.keys(releaseWorkflow.jobs).filter(name => name.startsWith('release_'));
for (const name of releaseJobs) {
const job = releaseWorkflow.jobs[name];
expect(job.steps.slice(-1)[0].run.startsWith('echo "DRY RUN:')).toBeTruthy();
}
});

0 comments on commit 47f2be9

Please sign in to comment.