Skip to content

Commit 858199e

Browse files
authored
feat(ocaml): update opam project.opam.locked files (googleapis#1325)
* test: Add tests in test/strategies/ocaml.ts (TDD) * feat: opam support for `project.opam.locked` files Close googleapis#1085
1 parent 91ebd9b commit 858199e

3 files changed

Lines changed: 37 additions & 2 deletions

File tree

src/strategies/ocaml.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ export class OCaml extends BaseStrategy {
7272
});
7373
});
7474

75+
const opamLockedPaths = await this.github.findFilesByExtension(
76+
'opam.locked',
77+
this.path
78+
);
79+
opamLockedPaths.filter(notEsyLock).forEach(path => {
80+
updates.push({
81+
path: this.addPath(path),
82+
createIfMissing: false,
83+
updater: new Opam({
84+
version,
85+
}),
86+
});
87+
});
88+
7589
updates.push({
7690
path: this.addPath('dune-project'),
7791
createIfMissing: false,
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
opam-version: "2.0"
2+
version: "0.5.0"
3+
synopsis: "A sample opam file"
4+
maintainer: "example@example.org"
5+
author: "Example"
6+
license: "Apache-2.0"
7+
homepage: "https://github.com/googleapis/release-please"
8+
dev-repo: "git+https://github.comgoogleapis/release-please.git"
9+
bug-reports: "https://github.com/googleapis/release-please/issues"
10+
build: [
11+
[ "dune" "subst" ] {pinned}
12+
[ "dune" "build" "-p" name "-j" jobs ]
13+
]
14+
depends: [
15+
"ocaml" {= "4.12.2"}
16+
"dune" {= "3.0.3"}
17+
]

test/strategies/ocaml.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,27 @@ describe('OCaml', () => {
119119
const findFilesStub = sandbox.stub(github, 'findFilesByExtension');
120120
findFilesStub.withArgs('json', '.').resolves(['esy.json', 'other.json']);
121121
findFilesStub.withArgs('opam', '.').resolves(['sample.opam']);
122+
findFilesStub
123+
.withArgs('opam.locked', '.')
124+
.resolves(['sample.opam.locked']);
122125
stubFilesFromFixtures({
123126
sandbox,
124127
github,
125128
targetBranch: 'main',
126129
fixturePath: fixturesPath,
127-
files: ['esy.json', 'other.json', 'sample.opam'],
130+
files: ['esy.json', 'other.json', 'sample.opam', 'sample.opam.locked'],
128131
});
129132
const latestRelease = undefined;
130133
const release = await strategy.buildReleasePullRequest(
131134
COMMITS,
132135
latestRelease
133136
);
134137
const updates = release!.updates;
135-
expect(updates).lengthOf(4);
138+
expect(updates).lengthOf(5);
136139
assertHasUpdate(updates, 'esy.json', EsyJson);
137140
assertNoHasUpdate(updates, 'other.json');
138141
assertHasUpdate(updates, 'sample.opam', Opam);
142+
assertHasUpdate(updates, 'sample.opam.locked', Opam);
139143
});
140144
});
141145
});

0 commit comments

Comments
 (0)