Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add ci #37

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 34 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]
tags:
- '*'

jobs:
build:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Npm install
run: npm ci
- name: Build
run: npm run compile
- name: Test (Linux)
if: runner.os == 'Linux'
run: xvfb-run -a npm test
- name: Test (Windows/Mac)
if: runner.os != 'Linux'
run: npm run test
2 changes: 1 addition & 1 deletion dprint.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"indentWidth": 2,
"includes": [
"**/*.{ts,tsx,js,jsx,json,md}"
],
"excludes": [
"**/node_modules",
"**/.vscode-test",
"**/*-lock.json",
"out"
],
Expand Down
180 changes: 90 additions & 90 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,91 +1,91 @@
{
"name": "dprint",
"displayName": "Dprint Code Formatter",
"description": "Formats code in VSCode using dprint.",
"author": "David Sherret",
"publisher": "dprint",
"version": "0.13.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dprint/dprint-vscode.git"
},
"engines": {
"vscode": "^1.45.0"
},
"categories": [
"Formatters"
],
"activationEvents": [
"onStartupFinished",
"onFileSystem:dprint"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "dprint.reset",
"title": "Dprint: Reset"
}
],
"configuration": {
"type": "object",
"title": "dprint",
"properties": {
"dprint.path": {
"type": [
"string",
"null"
],
"default": null,
"markdownDescription": "Specify a custom path for the dprint executable other than what's found on the path.",
"scope": "resource",
"examples": [
"/usr/bin/dprint",
"C:\\some-dir\\dprint.exe"
]
},
"dprint.verbose": {
"type": [
"boolean",
"null"
],
"default": false,
"markdownDescription": "Whether to enable verbose logging.",
"scope": "resource"
}
}
},
"jsonValidation": [
{
"fileMatch": "**/{dprint,.dprint,.dprintrc}.json",
"url": "dprint://schemas/config.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"run:extension": "code --extensionDevelopmentPath=.",
"watch": "npm run compile -- --watch",
"pretest": "tsc -p ./",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.1",
"@types/vscode": "^1.45.0",
"esbuild": "^0.14.29",
"glob": "^7.2.0",
"mocha": "^9.2.2",
"typescript": "^4.6.3",
"@vscode/test-electron": "^2.1.5"
},
"__metadata": {
"id": "a71f21fc-951b-4829-92f5-ba423b77109f",
"publisherDisplayName": "dprint",
"publisherId": "fbc6f234-24bc-436b-a1f7-81d06d444496",
"isPreReleaseVersion": false
}
}
"name": "dprint",
"displayName": "Dprint Code Formatter",
"description": "Formats code in VSCode using dprint.",
"author": "David Sherret",
"publisher": "dprint",
"version": "0.13.1",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/dprint/dprint-vscode.git"
},
"engines": {
"vscode": "^1.45.0"
},
"categories": [
"Formatters"
],
"activationEvents": [
"onStartupFinished",
"onFileSystem:dprint"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "dprint.reset",
"title": "Dprint: Reset"
}
],
"configuration": {
"type": "object",
"title": "dprint",
"properties": {
"dprint.path": {
"type": [
"string",
"null"
],
"default": null,
"markdownDescription": "Specify a custom path for the dprint executable other than what's found on the path.",
"scope": "resource",
"examples": [
"/usr/bin/dprint",
"C:\\some-dir\\dprint.exe"
]
},
"dprint.verbose": {
"type": [
"boolean",
"null"
],
"default": false,
"markdownDescription": "Whether to enable verbose logging.",
"scope": "resource"
}
}
},
"jsonValidation": [
{
"fileMatch": "**/{dprint,.dprint,.dprintrc}.json",
"url": "dprint://schemas/config.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"run:extension": "code --extensionDevelopmentPath=.",
"watch": "npm run compile -- --watch",
"pretest": "tsc -p ./",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "^16.11.1",
"@types/vscode": "^1.45.0",
"esbuild": "^0.14.29",
"glob": "^7.2.0",
"mocha": "^9.2.2",
"typescript": "^4.6.3",
"@vscode/test-electron": "^2.1.5"
},
"__metadata": {
"id": "a71f21fc-951b-4829-92f5-ba423b77109f",
"publisherDisplayName": "dprint",
"publisherId": "fbc6f234-24bc-436b-a1f7-81d06d444496",
"isPreReleaseVersion": false
}
}
9 changes: 6 additions & 3 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import * as path from "path";
import * as vscode from "vscode";
// import * as myExtension from '../../extension';

suite("Extension Test Suite", () => {
suite("Extension Test Suite", function() {
vscode.window.showInformationMessage("Start all tests.");
// create a temp folder
let tempNumber = 0;
let tempFolder = path.join(process.cwd(), "temp");
const isCI = process.env.CI != null;

this.timeout(isCI ? 40_000 : 4_000);

const context = {
get tempFolderUri() {
Expand Down Expand Up @@ -55,7 +58,7 @@ suite("Extension Test Suite", () => {
},
waitInitialize() {
// would be nice to do something better
return this.sleep(250);
return this.sleep(isCI ? 2_000 : 250);
},
async sleep(ms: number) {
await new Promise(resolve => setTimeout(resolve, ms));
Expand Down Expand Up @@ -162,7 +165,7 @@ suite("Extension Test Suite", () => {

// should be formatted
assert.equal(doc.getText(), `{\n "test": 5\n}\n`);
}).timeout(4_000);
});

async function applyTextChanges(doc: vscode.TextDocument, edits: vscode.TextEdit[]) {
const edit = new vscode.WorkspaceEdit();
Expand Down