Skip to content

Commit 9762a8f

Browse files
committed
☕ Check supported versions in CI
1 parent 30ff1ea commit 9762a8f

File tree

4 files changed

+140
-2
lines changed

4 files changed

+140
-2
lines changed

.github/workflows/test.yml

+19-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ on:
1111
- "deno.jsonc"
1212
- ".github/workflows/test.yml"
1313
workflow_dispatch:
14+
inputs:
15+
denops_branch:
16+
description: 'Denops revision to test'
17+
required: false
18+
default: 'main'
1419

1520
defaults:
1621
run:
1722
shell: bash --noprofile --norc -eo pipefail {0}
1823

24+
env:
25+
DENOPS_BRANCH: ${{ github.event.inputs.denops_branch || 'main' }}
26+
1927
jobs:
2028
check:
2129
strategy:
@@ -44,6 +52,11 @@ jobs:
4452
- name: Type check
4553
run: deno task check
4654

55+
- name: Supported version inconsistency check
56+
run: |
57+
deno task apply:supported-versions
58+
git diff --exit-code
59+
4760
test:
4861
strategy:
4962
matrix:
@@ -52,7 +65,7 @@ jobs:
5265
- macos-latest
5366
- ubuntu-latest
5467
deno_version:
55-
- "1.45.x"
68+
- "1.45.0"
5669
- "1.x"
5770
host_version:
5871
- vim: "v9.1.0448"
@@ -75,6 +88,11 @@ jobs:
7588
git clone https://github.com/vim-denops/denops.vim /tmp/denops.vim
7689
echo "DENOPS_TEST_DENOPS_PATH=/tmp/denops.vim" >> "$GITHUB_ENV"
7790
91+
- name: Try switching denops branch
92+
run: |
93+
git -C /tmp/denops.vim switch ${{ env.DENOPS_BRANCH }} || true
94+
git -C /tmp/denops.vim branch
95+
7896
- uses: rhysd/action-setup-vim@v1
7997
id: vim
8098
with:

.scripts/apply-supported-versions.ts

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import { ensure, is, type Predicate } from "jsr:@core/unknownutil@^4.0.0";
2+
3+
export type SupportedVersions = {
4+
deno: string;
5+
vim: string;
6+
neovim: string;
7+
};
8+
9+
const isSupportedVersions = is.ObjectOf({
10+
deno: is.String,
11+
vim: is.String,
12+
neovim: is.String,
13+
}) satisfies Predicate<SupportedVersions>;
14+
15+
function getSupportedVersionJsonUrl(branch: string): URL {
16+
return new URL(
17+
`https://raw.githubusercontent.com/vim-denops/denops.vim/${branch}/denops/supported_versions.json`,
18+
);
19+
}
20+
21+
export async function loadSupportedVersions(
22+
branch?: string,
23+
): Promise<SupportedVersions> {
24+
const url = getSupportedVersionJsonUrl(
25+
branch ?? Deno.env.get("DENOPS_BRANCH") ?? "main",
26+
);
27+
const resp = await fetch(url);
28+
const json = await resp.json();
29+
return ensure(json, isSupportedVersions);
30+
}
31+
32+
async function updateREADME(
33+
supportedVersions: SupportedVersions,
34+
): Promise<void> {
35+
const url = new URL(import.meta.resolve("../README.md"));
36+
let text = await Deno.readTextFile(url);
37+
// Deno
38+
text = text.replace(
39+
/Deno\s+\d+\.\d+\.\d+/,
40+
`Deno ${supportedVersions.deno}`,
41+
);
42+
text = text.replace(
43+
/Deno-Support%20\d+\.\d+\.\d+/,
44+
`Deno-Support%20${supportedVersions.deno}`,
45+
);
46+
text = text.replace(
47+
/https:\/\/github\.com\/denoland\/deno\/tree\/v\d+\.\d+\.\d+/,
48+
`https://github.com/denoland/deno/tree/v${supportedVersions.deno}`,
49+
);
50+
// Vim
51+
text = text.replace(
52+
/Vim\s+\d+\.\d+\.\d+/,
53+
`Vim ${supportedVersions.vim}`,
54+
);
55+
text = text.replace(
56+
/Vim-Support%20\d+\.\d+\.\d+/,
57+
`Vim-Support%20${supportedVersions.vim}`,
58+
);
59+
text = text.replace(
60+
/https:\/\/github\.com\/vim\/vim\/tree\/v\d+\.\d+\.\d+/,
61+
`https://github.com/vim/vim/tree/v${supportedVersions.vim}`,
62+
);
63+
// Neovim
64+
text = text.replace(
65+
/Neovim\s+\d+\.\d+\.\d+/,
66+
`Neovim ${supportedVersions.neovim}`,
67+
);
68+
text = text.replace(
69+
/Neovim-Support%20\d+\.\d+\.\d+/,
70+
`Neovim-Support%20${supportedVersions.neovim}`,
71+
);
72+
text = text.replace(
73+
/https:\/\/github\.com\/neovim\/neovim\/tree\/v\d+\.\d+\.\d+/,
74+
`https://github.com/neovim/neovim/tree/v${supportedVersions.neovim}`,
75+
);
76+
await Deno.writeTextFile(url, text);
77+
}
78+
79+
async function updateGithubWorkflowsTest(
80+
supportedVersions: SupportedVersions,
81+
): Promise<void> {
82+
const url = new URL(import.meta.resolve("../.github/workflows/test.yml"));
83+
let text = await Deno.readTextFile(url);
84+
// Deno
85+
text = text.replace(
86+
/deno_version:(.*?)"\d+\.\d+\.\d+"/s,
87+
`deno_version:$1"${supportedVersions.deno}"`,
88+
);
89+
// Vim
90+
text = text.replace(
91+
/vim:(.*?)"v\d+\.\d+\.\d+"/s,
92+
`vim:$1"v${supportedVersions.vim}"`,
93+
);
94+
// Neovim
95+
text = text.replace(
96+
/nvim:(.*?)"v\d+\.\d+\.\d+"/s,
97+
`nvim:$1"v${supportedVersions.neovim}"`,
98+
);
99+
await Deno.writeTextFile(url, text);
100+
}
101+
102+
async function main(): Promise<void> {
103+
const supportedVersions = await loadSupportedVersions();
104+
await updateREADME(supportedVersions);
105+
await updateGithubWorkflowsTest(supportedVersions);
106+
}
107+
108+
if (import.meta.main) {
109+
try {
110+
await main();
111+
} catch (error) {
112+
console.error(error);
113+
Deno.exit(1);
114+
}
115+
}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
[![Test](https://github.com/vim-denops/deno-denops-test/actions/workflows/test.yml/badge.svg)](https://github.com/vim-denops/deno-denops-test/actions/workflows/test.yml)
55
[![codecov](https://codecov.io/github/vim-denops/deno-denops-test/branch/main/graph/badge.svg?token=X9O5XB4O1S)](https://codecov.io/github/vim-denops/deno-denops-test)
66

7+
[![Deno 1.45.0 or above](https://img.shields.io/badge/Deno-Support%201.45.0-yellowgreen.svg?logo=deno)](https://github.com/denoland/deno/tree/v1.45.0)
8+
[![Vim 9.1.0448 or above](https://img.shields.io/badge/Vim-Support%209.1.0448-yellowgreen.svg?logo=vim)](https://github.com/vim/vim/tree/v9.1.0448)
9+
[![Neovim 0.10.0 or above](https://img.shields.io/badge/Neovim-Support%200.10.0-yellowgreen.svg?logo=neovim&logoColor=white)](https://github.com/neovim/neovim/tree/v0.10.0)
10+
711
A [Deno] module designed for testing [denops.vim]. This module is intended to be
812
used in the unit tests of denops plugins.
913

deno.jsonc

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"test:coverage": "deno task test --coverage=.coverage",
2828
"coverage": "deno coverage .coverage",
2929
"update": "deno run --allow-env --allow-read --allow-write=. --allow-run=git,deno --allow-net=jsr.io,registry.npmjs.org jsr:@molt/cli ./*.ts",
30-
"update:commit": "deno task -q update --commit --pre-commit=fmt,lint"
30+
"update:commit": "deno task -q update --commit --pre-commit=fmt,lint",
31+
"apply:supported-versions": "deno run --allow-env --allow-net --allow-read --allow-write .scripts/apply-supported-versions.ts"
3132
},
3233
"imports": {
3334
"jsr:@denops/test": "./mod.ts"

0 commit comments

Comments
 (0)