Skip to content

Commit

Permalink
Add infrastructure to release/publish as part of CI
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Dumais <[email protected]>

simplify workflow

Signed-off-by: Marc Dumais <[email protected]>

add release workflow

Signed-off-by: Marc Dumais <[email protected]>

Add initial RELEASE file

It's used by action pipe-cd/actions-gh-release . It will also
require the initial tag in the git repo, which I will add
separately.

Signed-off-by: Marc Dumais <[email protected]>

correct main branch name in release workflow

Signed-off-by: Marc Dumais <[email protected]>

massage package.json

Signed-off-by: Marc Dumais <[email protected]>

more small workflow edits

Signed-off-by: Marc Dumais <[email protected]>

add icon for extension

For now reusing the same one as vscode-trace-extension

Signed-off-by: Marc Dumais <[email protected]>

Add format check scripts and run in workflow

yarn format:check runs prettier on the sources and makes sure
it's presentable

Signed-off-by: Marc Dumais <[email protected]>

README update

Split the README into README-dev.md for developers and README.md for users. The later
will be included and shown on the extension registry and in the extensions view,  when
the extension is selected.

Signed-off-by: Marc Dumais <[email protected]>
  • Loading branch information
marcdumais-work committed Feb 6, 2024
1 parent bd538d7 commit be3d9b3
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 143 deletions.
106 changes: 62 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,76 +1,94 @@
name: build
name: CI/CD

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types:
- published

jobs:

build:
build-test:
name: Build and Test
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest]
node-version: [16.x]
node-version: [16]

steps:
- name: install dependencies on ubuntu
if: startsWith(matrix.os,'ubuntu')
run: |
sudo apt install -y make gcc pkg-config build-essential libx11-dev libxkbfile-dev
- uses: actions/checkout@v2

- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Cache node_modules with yarn
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn --frozen-lockfile

tests:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: yarn
- name: Run tests
uses: coactions/setup-xvfb@v1
with:
run: yarn test
- name: Package as VSCode Extension
run: yarn vsce:package
# Save the extension .vsix file for potential publishing
# in later step (if appropriate)
- uses: actions/upload-artifact@v4
with:
name: extension
path: vscode-trace-server-*.vsix

code-lint:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16]

steps:
- name: Check out Git repository
uses: actions/checkout@v2

- uses: actions/setup-node@v1
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'

node-version: ${{ matrix.node-version }}
# ESLint and Prettier must be in `package.json`
- run: yarn --frozen-lockfile --ignore-scripts
- name: Run lint
run: yarn lint
- name: Run format check
run: yarn format:check

- run: yarn lint
publish:
name: Publish extension to openvsx.org
runs-on: ${{ matrix.os }}
needs:
- build-test
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16]
# Only execute when the trigger was a tag (new release)
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags/v')

steps:
- uses: actions/checkout@v3
# restore extension from the built-test job
- uses: actions/download-artifact@v4
with:
name: extension
path: vscode-trace-extension
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn --frozen-lockfile --ignore-scripts
- name: Publish extension
run: |
ls -al vscode-trace-server-*.vsix
npx ovsx publish vscode-trace-server-*.vsix
env:
# have ovsx consume the PAT from environment - if it's not handled explicitly
# in the workflow, less risk to leak it
OVSX_PAT: ${{ secrets.OPEN_VSX_TOKEN }}

37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Create or prepare GitHub release

on:
push:
branches:
- main
paths:
- 'RELEASE'
pull_request:
types: [opened, synchronize]
branches:
- main
paths:
- 'RELEASE'

jobs:
gh-release:
name: GitHub release
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: pipe-cd/[email protected]
with:
release_file: 'RELEASE'
# Actions that run using the auto-generated GitHub token are
# not allowed to trigger a new workflow run. In this case we want
# the tag created by actions-gh-release to trigger the main workflow
# and result in publishing the extension to open-vsx.
# The following scopes are required when creating the committer token:
# - repo:status, repo_deployment, public_repo, read:org
# See here for more details:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow
token: ${{ secrets.GH_COMMITTER_TOKEN }}

106 changes: 106 additions & 0 deletions README-dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# VSCode Trace Server extension

This file contains information that could be interesting to developers, that want to mnodify, build, test, and debug this extension.

For general information, see the main [README.md](README.md)


* This is a TypeScript extension, officially named `vscode-trace-server`.
* It is meant as companion to the [vscode-trace-extension][vscode-trace-extension].
* It registers `Trace Server:` start/stop commands, for a default instance locally.
* It depends on the [tsp-typescript-client][client] for server health check purposes.

This extension was started from Code's [guide][guide] and related [sample][sample].

## Documentation

This README is the usual entry point for documenting this extension.

* One may refer to the [contribution guide](CONTRIBUTING.md) for how to contribute.
* Please also refer to the [security policy](SECURITY.md) on a need basis.
* The usual [license description](LICENSE.md) file accompanies these too.

## Build

Run `yarn`, which should automatically include `yarn install`.

* This extension is bundled using `webpack`, originally based on [the guide][guide].
* There is only a modest automated CI test suite being run on GitHub

## Test

Run `yarn test` on a need basis.

Alternatively, launch `Extension Tests` under `Run and Debug`.

## Installation

1. After [having built](#build) at least once, run `yarn vsce:package` ([more][vsce]) at will.
1. [Install][install] the hereby generated `vscode-trace-server-*.vsix` file.
1. Alternatively, simply launch the packaged extension using `Run Extension`.
1. Through `Command Palette`, the `Trace Server:` start/stop commands should be available.

This extension can be installed in either one (or many) of:

* [VS Code][code] or [Codium][codium]/Code-OSS, or
* a [Theia][theia] application such as [Blueprint][blueprint].

The dependent [Trace Viewer for VSCode][vscode-trace-extension] extension renders a `Trace Server`
[status bar item][item]. A note:

Reinstalling an amended extension that has the same version requires removing the unpacked extension, found under one of the following folders:

* [Theia Blueprint][blueprint]: extracts installed extensions under `/tmp/vscode-unpacked/`.
* VSCode: extracts the installed extensions under the user's home, in folder `.vscode/extensions/`.

Alternatively, you may step the extension's version to avoid this issue.

## Debugging

* One may launch the extension using `Run Extension`, to debug it with breakpoints, as usual.
* The same can be done for tests, launching `Extension Tests` to debug them.
* The enabled breakpoints get bound only upon exercising the extension.

## Development

The usual [Prettier][prettier] and [ESLint][eslint] combo in VS Code or Codium OSS is used.

* [This matcher][matcher] is also used, since the originally generated extension per [guide].
* Markdown gets linted with the (usual) [vscode-markdownlint][markdownlint] extension.
* [SonarLint][sonarlint] is also assumed while further developing this extension.

These are actual [recommended extensions herein](.vscode/extensions.json).

* Beside using [the extension][prettier], one may run `prettier` from the CLI:

```bash
# confirm formatting is ok:
yarn format:check
# correct the formatting:
yarn format:write

```

## Status

This extension is currently under [initial development][backlog].

[backlog]: https://github.com/eclipse-cdt-cloud/vscode-trace-extension/issues/15
[blueprint]: https://theia-ide.org/docs/blueprint_download
[client]: https://github.com/eclipse-cdt-cloud/tsp-typescript-client
[code]: https://code.visualstudio.com
[codium]: https://vscodium.com
[eslint]: https://open-vsx.org/extension/dbaeumer/vscode-eslint
[guide]: https://code.visualstudio.com/api/get-started/your-first-extension
[install]: https://code.visualstudio.com/docs/editor/extension-marketplace#_install-from-a-vsix
[item]: https://github.com/eclipse-cdt-cloud/vscode-trace-extension/pull/120
[markdownlint]: https://open-vsx.org/extension/DavidAnson/vscode-markdownlint
[matcher]: https://open-vsx.org/extension/amodio/tsl-problem-matcher
[prettier]: https://open-vsx.org/extension/esbenp/prettier-vscode
[sample]: https://github.com/microsoft/vscode-extension-samples/blob/main/helloworld-sample
[server]: https://git.eclipse.org/r/plugins/gitiles/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/refs/heads/master/trace-server/#running-the-server
[sonarlint]: https://open-vsx.org/extension/SonarSource/sonarlint-vscode
[theia]: https://theia-ide.org
[tsp]: https://github.com/eclipse-cdt-cloud/trace-server-protocol
[vsce]: https://code.visualstudio.com/api/working-with-extensions/publishing-extension#vsce
[vscode-trace-extension]: https://github.com/eclipse-cdt-cloud/vscode-trace-extension
Loading

0 comments on commit be3d9b3

Please sign in to comment.