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
The added infrastructure is similar to what we recently added in the
vscode-trace-extension repo. The idea is to automate creating a GitHub
release and corresponding git tag, as well as the publishing to vscode
extension registries (open-vsx.org to start-with).

To achieve that, a new GitHub workflow was created: "release", that uses
action "pipe-cd/actions-gh-release" to automatically create a GitHub release
containing release notes generated from commits and a git tag. The trigger
for that to happen is the modification of root file "RELEASE" to include
a new release tag.

We also renamed workflow "build" to "ci-cd" and updated it. It now has a
publish job, that triggers upon a new release being created, and publishes
the extension in "vsix" format to open-vsx.org.

To prepare for the first release/publish, we also updated the extension's
README, factoring-out the developer-centric information to its own file
and keeping a minimal first draft of the README that will be shown to the
end-users on the extension registry and in the extensions view. Also
updated the extension's package.json to have the necessary fields and
information, for a published extension.

Once this is merged, if everything works as expected, all that will be
needed for a first release will be to update the tag in file RELEASE to
the release version and update the extension's version in package.json
to the same.

See below for some more info about the changes made, that
were squashed into this single commit.

add release workflow

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.

massage package.json

add icon for extension

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

Add format check scripts and run in workflow

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

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 7, 2024
1 parent bd538d7 commit f183ad3
Show file tree
Hide file tree
Showing 9 changed files with 275 additions and 175 deletions.
76 changes: 0 additions & 76 deletions .github/workflows/build.yml

This file was deleted.

93 changes: 93 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI/CD

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

jobs:

build-test:
name: Build and Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: yarn --frozen-lockfile
- 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: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [16]

steps:
- name: Check out Git repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
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

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
- 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 f183ad3

Please sign in to comment.