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

Add GitHub actions #182

Merged
merged 11 commits into from
May 4, 2021
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on:
push:
paths-ignore:
- "examples/json-extension/**"
pull_request:
paths-ignore:
- "examples/json-extension/**"

jobs:
test:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8"]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2

- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install Python dependencies
run: python -m pip install --upgrade pip tox

- name: tox
run: tox -e py

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Use Python
uses: actions/setup-python@v2
with:
python-version: "3.x"

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"

- name: pip cache
uses: actions/cache@v2
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-

- name: Install Python dependencies
run: python -m pip --disable-pip-version-check install --upgrade setuptools wheel

- name: Build sdist
run: python setup.py sdist

- name: Build wheel
run: python setup.py bdist_wheel

- name: Upload builds
uses: actions/upload-artifact@v2
with:
name: build-artifacts
path: "build/*"
81 changes: 81 additions & 0 deletions .github/workflows/json-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: JSON language server

on:
push:
paths:
- ".github/workflows/json-extension.yml"
- "examples/json-extension/**"
pull_request:
paths:
- ".github/workflows/json-extension.yml"
- "examples/json-extension/**"

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
shell: bash
working-directory: examples/json-extension

steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
with:
python-version: "3.x"

- uses: actions/setup-node@v2
with:
node-version: "12"

- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('examples/json-extension/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: |
npm i
npm i vsce

- name: Lint
run: npx eslint client/src/*.ts

- name: Compile
run: npm run compile

- name: Replace package.json version
run: |
replace_packagejson_version() {
version_line=$(grep -o '"version".*' $1)
version=$(python -m json.tool package.json | awk -F'"' '/version/{print $4}')
build_version=$version+$2
build_version_line=${version_line/$version/$build_version}
sed -i "s|$version_line|$build_version_line|g" $1
}

replace_packagejson_version package.json $GITHUB_RUN_ID

- name: Build VSIX
run: npx vsce package

- name: Validate VSIX
run: |
npx vsce ls | grep package.json
npx vsce ls | grep out/extension.js
npx vsce ls | grep server/__init__.py
npx vsce ls | grep server/__main__.py
npx vsce ls | grep server/server.py

- name: Upload VSIX
uses: actions/upload-artifact@v2
with:
name: json-extension-vsix
# The path must be rooted from the directory GitHub Actions starts
# from, not the working-directory.
path: examples/json-extension/*.vsix
if-no-files-found: error
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contributors (alphabetical)

- [@augb](https://github.com/augb)
- [Brett Cannon](https://github.com/brettcannon/)
- [Daniel Elero](https://github.com/danixeee)
- [Daniel Miller](https://github.com/millerdev)
- [DeathAxe](https://github.com/deathaxe)
Expand Down
13 changes: 13 additions & 0 deletions examples/json-extension/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
env:
es2021: true
node: true
extends:
- 'eslint:recommended'
- 'plugin:@typescript-eslint/recommended'
parser: '@typescript-eslint/parser'
parserOptions:
ecmaVersion: 12
sourceType: module
plugins:
- '@typescript-eslint'
rules: {}
4 changes: 2 additions & 2 deletions examples/json-extension/client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function isStartedInDebugMode(): boolean {

function startLangServerTCP(addr: number): LanguageClient {
const serverOptions: ServerOptions = () => {
return new Promise((resolve, reject) => {
return new Promise((resolve /*, reject */) => {
const clientSocket = new net.Socket();
clientSocket.connect(addr, "127.0.0.1", () => {
resolve({
Expand Down Expand Up @@ -82,7 +82,7 @@ function startLangServer(
return new LanguageClient(command, serverOptions, getClientOptions());
}

export function activate(context: ExtensionContext) {
export function activate(context: ExtensionContext): void {
if (isStartedInDebugMode()) {
// Development - Run the server manually
client = startLangServerTCP(2087);
Expand Down
4 changes: 2 additions & 2 deletions examples/json-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions examples/json-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
"devDependencies": {
"@types/node": "^14.14.41",
"@types/vscode": "^1.55.0",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.23.0",
"typescript": "^4.2.4"
},
Expand Down