Skip to content

Commit

Permalink
Add launchable into CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ono-max committed Feb 6, 2024
1 parent fd4ed3a commit f7837f3
Show file tree
Hide file tree
Showing 6 changed files with 221 additions and 4 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ on:
branches:
- master

env:
LAUNCHABLE_TEST_REPORTS: "launchable-test-reports.xml"
# GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App.
# https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42
GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }}
# The following envs are necessary in Launchable tokenless authentication.
# https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20
LAUNCHABLE_ORGANIZATION: "ruby"
LAUNCHABLE_WORKSPACE: "vscode-rdbg"
# https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71
GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

jobs:
test:
strategy:
Expand All @@ -18,6 +30,25 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Set fetch-depth: 0 so that Launchable can receive commits information.
fetch-depth: 0
# Launchable requires Python and Java
# https://www.launchableinc.com/docs/resources/cli-reference/
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Setup Launchable
run: |
pip install launchable
launchable verify
launchable record build --name "$GITHUB_PR_HEAD_SHA"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down Expand Up @@ -48,6 +79,9 @@ jobs:
if: runner.os == 'macOS'
- run: npm test
if: runner.os != 'Linux'
- name: Record tests with Launchable
run: launchable record tests --flavor os=${{ matrix.os }} --flavor test=integration_test file $LAUNCHABLE_TEST_REPORTS
if: always()

dependabot:
needs: test
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/ui-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,45 @@ on:
# This job runs at 00:00 UTC every day.
- cron: '0 0 * * *'

env:
LAUNCHABLE_TEST_REPORTS: "launchable-test-reports.xml"
# GITHUB_PULL_REQUEST_URL are used for commenting test reports in Launchable Github App.
# https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/link.py#L42
GITHUB_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }}
# The following envs are necessary in Launchable tokenless authentication.
# https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L20
LAUNCHABLE_ORGANIZATION: "ruby"
LAUNCHABLE_WORKSPACE: "vscode-rdbg"
# https://github.com/launchableinc/cli/blob/v1.80.1/launchable/utils/authentication.py#L71
GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# Set fetch-depth: 0 so that Launchable can receive commits information.
fetch-depth: 0
# Launchable requires Python and Java
# https://www.launchableinc.com/docs/resources/cli-reference/
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Set up JDK 1.8
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Setup Launchable
run: |
pip install launchable
launchable verify
: # The build name must be a unique identifier for this build. Therefore, $GITHUB_RUN_ID is appropriate in this case.
: # https://www.launchableinc.com/docs/sending-data-to-launchable/using-the-launchable-cli/recording-builds-with-the-launchable-cli/
launchable record build --name "$GITHUB_RUN_ID"
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -22,3 +55,6 @@ jobs:
- run: gem install debug
- run: npm install @types/[email protected]
- run: xvfb-run -a npm run ui-test
- name: Record tests with Launchable
run: launchable record tests --flavor os=ubuntu-latest --flavor test=e2e_test file $LAUNCHABLE_TEST_REPORTS
if: always()
129 changes: 129 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@
"eslint-config-prettier": "^9.1.0",
"glob": "^8.1.0",
"mocha": "^10.2.0",
"mocha-junit-reporter": "^2.2.1",
"prettier": "^3.2.5",
"typescript": "^5.3.3",
"vscode-extension-tester": "^7.0.0"
Expand Down
15 changes: 12 additions & 3 deletions src/test/suite/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import * as path from "path";
import * as Mocha from "mocha";
import * as glob from "glob";
import { MochaOptions } from "mocha";

export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
const mochaOpts: MochaOptions = {
ui: "tdd",
color: true
});
}
const testReports = process.env.LAUNCHABLE_TEST_REPORTS
if (testReports) {
mochaOpts.reporter = 'mocha-junit-reporter';
mochaOpts.reporterOptions = {
mochaFile: testReports
}
}
// Create the mocha test
const mocha = new Mocha(mochaOpts);

mocha.timeout("20000");

Expand Down
10 changes: 9 additions & 1 deletion src/ui-test/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { MochaOptions } from "vscode-extension-tester";

const options: MochaOptions = {
timeout: 180000,
timeout: 180000,
};

const testReports = process.env.LAUNCHABLE_TEST_REPORTS;
if (testReports) {
options.reporter = "mocha-junit-reporter";
options.reporterOptions = {
mochaFile: testReports,
};
}

module.exports = options;

0 comments on commit f7837f3

Please sign in to comment.