Skip to content

Commit

Permalink
ci: add a basic testsuite and github workflows
Browse files Browse the repository at this point in the history
- update dependencies
- update docs and extension info
  • Loading branch information
jsenko committed Apr 12, 2024
1 parent e37f870 commit 3fc6e28
Show file tree
Hide file tree
Showing 15 changed files with 488 additions and 37 deletions.
23 changes: 15 additions & 8 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
## Description
Describe your changes in detail

## Related Issue
<!--
Describe your changes in detail. Why is this change required? What problem does it solve?
-->

If fixing a bug, there should be an issue describing it with steps to reproduce
Please link to the issue here:
## Related Issues

## Motivation and Context
Why is this change required? What problem does it solve?
<!--
If fixing a bug, there should be an issue describing it, with steps to reproduce. Please link to the issue here.
-->

## How Has This Been Tested?

<!--
Please describe in detail how you tested your changes.
Include details of your testing environment, and the tests you ran to see how your change affects other areas of the code, etc.
-->

<!--
## Screenshots
## Screenshots (if appropriate)
(If appropriate.)
-->
123 changes: 123 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Release

on:
workflow_dispatch:
inputs:
branch:
description: Branch to release from
required: true
default: main
release-version:
description: Version being released (e.g. 7.8.9)
required: true
next-version:
description: Version after the release (e.g. 7.8.10-dev)
required: true
# pre-release:
# type: boolean
# description: Create a pre-release version
# required: true
# default: true
changelog:
type: boolean
description: I have updated the CHANGELOG.md file
required: true
default: false
debug:
type: boolean
description: Debug with tmate on failure
required: true
default: true

jobs:
test:
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio'
steps:
- name: Check prerequisites
if: ${{ !inputs.changelog }}
run: |
exit 1
- name: Set up npm
uses: actions/setup-node@v4
with:
node-version: 18

- name: Set up vsce
run: |
npm install -g @vscode/vsce
- name: Set up ovsx
run: |
npm install -g ovsx
- name: Checkout
run: |
git init
git config user.name apicurio-ci
git config user.email apicurio.ci@gmail.com
git remote add origin "https://apicurio-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apicurio/apicurio-registry-vscode-plugin.git"
git fetch
git checkout --track "origin/${{ inputs.branch }}"
- name: Dependencies
run: |
npm install
- name: Compile
run: |
npm run compile
- name: Run Registry
run: |
echo "REGISTRY_CID=$(docker run -d -p 8080:8080 quay.io/apicurio/apicurio-registry-mem:2.5.x-snapshot)" >> "$GITHUB_ENV"
- name: Test
run: |
xvfb-run -a npm run test
- name: Stop Registry
run: |
docker stop "$REGISTRY_CID"
# - name: Configure pre-release
# if: ${{ inputs.pre-release }}
# run: |
# echo "PRE_RELEASE=--pre-release" >> "$GITHUB_ENV"

# - name: Configure release
# if: ${{ !inputs.pre-release }}
# run: |
# echo "PRE_RELEASE=" >> "$GITHUB_ENV"

- name: Package
run: |
vsce package -m "Update to release version ${{ inputs.release-version }}" "${{ inputs.release-version }}"
echo "VSIX_FILE=apicurio-registry-explorer-${{ inputs.release-version }}.vsix" >> "$GITHUB_ENV"
- name: Publish with vsce
run: |
vsce publish -i "$VSIX_FILE" -p "${{ secrets.VSCODE_MARKETPLACE_ACCESS_TOKEN }}"
- name: Publish with ovsx
run: |
ovsx publish -i "$VSIX_FILE" -p "${{ secrets.OVSX_REGISTRY_ACCESS_TOKEN }}"
- name: Next version
# if: ${{ !inputs.pre-release }}
run: |
npm version --no-git-tag-version ${{ inputs.next-version }}
git commit -m "Update to next development version ${{ inputs.next-version }}"
- name: Push
# if: ${{ !inputs.pre-release }}
run: |
git push origin "${{ inputs.branch }}"
git push origin "v${{ inputs.release-version }}"
# TODO: Create a GitHub release

- name: Setup tmate session
if: failure() && inputs.debug
uses: mxschmitt/action-tmate@v3
46 changes: 46 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
if: github.repository_owner == 'Apicurio'
steps:
- name: Set up npm
uses: actions/setup-node@v4
with:
node-version: 18

- name: Checkout
uses: actions/checkout@v3

- name: Dependencies
run: |
npm install
- name: Compile
run: |
npm run compile
- name: Run Registry
run: |
echo "REGISTRY_CID=$(docker run -d -p 8080:8080 quay.io/apicurio/apicurio-registry-mem:2.5.x-snapshot)" >> "$GITHUB_ENV"
- name: Test
run: |
xvfb-run -a npm run test
- name: Stop Registry
run: |
docker stop "$REGISTRY_CID"
# - name: Setup tmate session
# if: failure()
# uses: mxschmitt/action-tmate@v3
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.DS_Store
.vscode/settings.json
*.vsix
out
.idea
.test-extensions
.trash~
.vscode/settings.json
node_modules
yarn.lock
out
package-lock.json
.idea
17 changes: 10 additions & 7 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
.vscode/**
.vscode-test/**
out/test/**
test/**
src/**
**/*.map
.github
.gitignore
.idea
.test-extensions
.trash~
.vscode
out/test
out/*.js.map
settings.json
src
test-resources
tsconfig.json
vsc-extension-quickstart.md
42 changes: 35 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ When contributing to this repository, please first discuss the change you wish t

Please note that this project is maintain on free personal time, be kind and do not except immediate answers.

## Prereqisites
## Prerequisites

This extension is best developed in Visual Studio Code (VSC) itself. Even if you use other IDE to edit the code, VSC is required for debugging.

Expand All @@ -22,12 +22,12 @@ To set up your VSC, install the following extensions:

Run **ctrl+P** and then `ext install dbaeumer.vscode-eslint`.

### Run Apicurio Registry
### Apicurio Registry

You can run a local Apicurio Registry instance with docker:
You need Apicurio Registry during development, or to run the testsuite. You can run a local instance with docker:

```sh
docker run -it -p 8080:8080 apicurio/apicurio-registry-mem:latest-release
docker run -it -p 8080:8080 quay.io/apicurio/apicurio-registry-mem:2.5.x-snapshot
```

It will be available at http://localhost:8080.
Expand All @@ -40,17 +40,45 @@ To package the extension for publishing, you need the `vsce` executable, which c
npm install -g @vscode/vsce
```

## Install
## Dependencies

```sh
npm install
```

## Developp
## Develop

Use the **Run and Debug** panel to run and debug the extension. Make sure the **Run Extension** task is selected and press **F5**.

The task will compile the extention and launch a VSC instance with the extension loaded.
The task will compile the extension and launch a VSC instance with the extension loaded.

## Compile

```sh
npm run compile
```

or

```sh
npm run vscode:prepublish
```

## Test

To run the testsuite, an Apicurio Registry instance at `localhost:8080` is required.

```sh
npm run test
```

or

```sh
npm run test-no-timeout
```

without the default Mocha promise timeout.

## Package

Expand Down
27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "apicurio-registry-explorer",
"displayName": "Apicurio registry",
"description": "Explore Apicurio registry content.",
"displayName": "Apicurio Registry Explorer",
"description": "Explore Apicurio Registry content.",
"version": "1.0.1",
"publisher": "apicurio",
"publisher": "Apicurio",
"author": {
"name": "Apicurio",
"url": "https://www.apicur.io/"
Expand All @@ -14,7 +14,7 @@
"url": "https://github.com/Apicurio/apicurio-registry-vscode-plugin.git"
},
"engines": {
"vscode": "^1.57.0"
"vscode": "^1.82.0"
},
"categories": [
"Visualization"
Expand Down Expand Up @@ -222,15 +222,22 @@
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"lint": "eslint . --ext .ts,.tsx"
"lint": "eslint . --ext .ts,.tsx",
"test": "extest setup-and-run './out/test/*-test.js' --code_settings settings.json --extensions_dir .test-extensions",
"test-no-timeout": "extest setup-and-run './out/test/*-test.js' --code_settings settings.json --extensions_dir .test-extensions --mocha_config './src/test/.mocharc-debug.js'"
},
"devDependencies": {
"@types/node": "^17.0.12",
"@types/vscode": "^1.52.0",
"@typescript-eslint/eslint-plugin": "^5.10.1",
"eslint": "^8.7.0",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.25",
"@types/vscode": "^1.82.0",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"chai": "^4.4.1",
"eslint": "^8.57.0",
"mocha": "^10.3.0",
"prettier": "3.2.4",
"typescript": "^4.5.5"
"typescript": "^5.3.3",
"vscode-extension-tester": "^7.2.0"
},
"dependencies": {
"http": "^0.0.1-security",
Expand Down
6 changes: 6 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"typescript.updateImportsOnFileMove.enabled": "always",
"workbench.editor.enablePreview": true,
"git.autoRepositoryDetection": false,
"terminal.integrated.sendKeybindingsToShell": true
}
3 changes: 3 additions & 0 deletions src/test/.mocharc-debug.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
timeout: 999999999
}
Loading

0 comments on commit 3fc6e28

Please sign in to comment.