Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20


- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn

run: yarn install --immutable

- name: Lint and test
run: xvfb-run -a yarn test

- name: Build
run: yarn package

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: "*.vsix"
retention-days: 10
retention-days: 10
18 changes: 14 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn
run: yarn install --immutable
- name: Package extension
id: package
run: |
echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"
yarn package
- name: Publish to Open VSX Registry
uses: HaaLeo/publish-vscode-extension@v1
id: publishToOpenVSX
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.OPEN_VSX_TOKEN }}
extensionFile: koishi-dev-${{ steps.package.outputs.version }}.vsix
- name: Publish to Visual Studio Marketplace
uses: HaaLeo/publish-vscode-extension@v1
uses: HaaLeo/publish-vscode-extension@v2
with:
pat: ${{ secrets.VS_MARKETPLACE_TOKEN }}
registryUrl: https://marketplace.visualstudio.com
extensionFile: ${{ steps.publishToOpenVSX.outputs.vsixPath }}
35 changes: 15 additions & 20 deletions .github/workflows/tagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,33 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: Check current version
id: check_version
run: echo ::set-output name=VERSION::$(node -p "require('./package.json').version")

- name: Check remote tags
id: check_tags
run: |
git fetch --tags
echo ::set-output name=TAGS::$(git tag -l)
run: echo "version=$(node -p "require('./package.json').version")" >> "$GITHUB_OUTPUT"

- name: Check if tag exists
id: check_tag
run: |
if [[ "${{ steps.check_tags.outputs.TAGS }}" == *"${{ steps.check_version.outputs.VERSION }}"* ]]; then
echo ::set-output name=TAG_EXISTS::true
if git tag -l "v${VERSION}" | grep -q .; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo ::set-output name=TAG_EXISTS::false
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
env:
VERSION: ${{ steps.check_version.outputs.version }}

- name: Create tag
id: create_tag
if: ${{ github.ref == 'refs/heads/master' && steps.check_tag.outputs.TAG_EXISTS == 'false' }}
run: echo ::set-output name=TAG::v${{ steps.check_version.outputs.VERSION }}

- name: Push tag
if: ${{ github.ref == 'refs/heads/master' && steps.check_tag.outputs.TAG_EXISTS == 'false' }}
- name: Create and push tag
if: ${{ steps.check_tag.outputs.exists == 'false' }}
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git tag ${{ steps.create_tag.outputs.TAG }}
git push origin ${{ steps.create_tag.outputs.TAG }}
git tag "v${VERSION}"
git push origin "v${VERSION}"
env:
VERSION: ${{ steps.check_version.outputs.version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ dist/
out

# VSCode
.vscode-test/

# Plugin
schemata/*.json
Expand Down
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ src/**
.gitignore
.yarnrc
.yarnrc.yml
.yarn/**
**/tsconfig.json
**/.eslintrc.json
**/eslint.config.mjs
Expand Down
7 changes: 6 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
nodeLinker: node-modules
approvedGitRepositories:
- "**"

enableScripts: true

nodeLinker: node-modules
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"description": "VSCode extension for Koishi developers",
"version": "0.0.4",
"license": "AGPL-3.0",
"packageManager": "yarn@4.14.1",
"engines": {
"vscode": "^1.140.0"
},
Expand All @@ -13,11 +14,9 @@
"compile": "tsc -p ./",
"convert": "tsx ./scripts/convert.ts",
"watch": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"lint": "eslint src",
"test": "node ./out/test/runTest.js",

"package": "vsce package"
"test": "yarn run compile && yarn run lint && node ./out/test/runTest.js",
"package": "vsce package --no-yarn"
},
"repository": {
"type": "git+https",
Expand Down
42 changes: 18 additions & 24 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from 'path'
import * as Mocha from 'mocha'
import * as glob from 'glob'
import { globSync } from 'glob'

export function run(): Promise<void> {
export async function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
Expand All @@ -11,28 +11,22 @@ export function run(): Promise<void> {

const testsRoot = path.resolve(__dirname, '..')

return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err)
}
// Add files to the test suite
globSync('**/**.test.js', { cwd: testsRoot }).forEach((f) =>
mocha.addFile(path.resolve(testsRoot, f)),
)

// Add files to the test suite
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)))

try {
// Run the mocha test
mocha.run((failures) => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`))
} else {
c()
}
})
} catch (err) {
console.error(err)
e(err)
}
})
// Run the mocha test
const failures = await new Promise<number>((c, e) => {
try {
mocha.run(c)
} catch (err) {
console.error(err)
e(err)
}
})

if (failures > 0) {
throw new Error(`${failures} tests failed.`)
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"declarationMap": true
},
"include": ["src/**/*.ts"],
"exclude": ["src/test/**/*", "out/**/*", "scripts/**/*"]
"exclude": ["out/**/*", "scripts/**/*"]
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Manual changes might be lost - proceed with caution!

__metadata:
version: 8
version: 9
cacheKey: 10c0

"@azure/abort-controller@npm:^2.0.0, @azure/abort-controller@npm:^2.1.2":
Expand Down
Loading