From 0d3272c365d93edd99a9e3cf1ce9871c1ca98d53 Mon Sep 17 00:00:00 2001 From: Naoto Ono Date: Tue, 6 Feb 2024 12:45:18 +0900 Subject: [PATCH] Add launchable into CI --- .github/workflows/test.yml | 34 +++++++++ .github/workflows/ui-test.yaml | 36 +++++++++ package-lock.json | 129 +++++++++++++++++++++++++++++++++ package.json | 1 + src/test/suite/index.ts | 15 +++- src/ui-test/config.ts | 10 ++- 6 files changed, 221 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c6d76eb4..278d1c56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: @@ -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 "${{ env.GITHUB_PR_HEAD_SHA }}" + - name: Set up Ruby uses: ruby/setup-ruby@v1 with: @@ -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 ${{ env.LAUNCHABLE_TEST_REPORTS }} + if: always() dependabot: needs: test diff --git a/.github/workflows/ui-test.yaml b/.github/workflows/ui-test.yaml index 23ec6dbb..3ad210c8 100644 --- a/.github/workflows/ui-test.yaml +++ b/.github/workflows/ui-test.yaml @@ -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: @@ -22,3 +55,6 @@ jobs: - run: gem install debug - run: npm install @types/vscode@1.65.0 - 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() diff --git a/package-lock.json b/package-lock.json index 55fe6c88..605cbca8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,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" @@ -1192,6 +1193,15 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/cheerio": { "version": "1.0.0-rc.12", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", @@ -1364,6 +1374,15 @@ "node": ">= 8" } }, + "node_modules/crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/css-select": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", @@ -2576,6 +2595,12 @@ "node": ">=8" } }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, "node_modules/is-docker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", @@ -2993,6 +3018,17 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dev": true, + "dependencies": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "node_modules/mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", @@ -3149,6 +3185,37 @@ "url": "https://opencollective.com/mochajs" } }, + "node_modules/mocha-junit-reporter": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.2.1.tgz", + "integrity": "sha512-iDn2tlKHn8Vh8o4nCzcUVW4q7iXp7cC4EB78N0cDHIobLymyHNwe0XG8HEHHjc3hJlXm0Vy6zcrxaIhnI2fWmw==", + "dev": true, + "dependencies": { + "debug": "^4.3.4", + "md5": "^2.3.0", + "mkdirp": "^3.0.0", + "strip-ansi": "^6.0.1", + "xml": "^1.0.1" + }, + "peerDependencies": { + "mocha": ">=2.2.5" + } + }, + "node_modules/mocha-junit-reporter/node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/mocha/node_modules/glob": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz", @@ -4710,6 +4777,12 @@ } } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "node_modules/xml2js": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", @@ -5646,6 +5719,12 @@ "supports-color": "^7.1.0" } }, + "charenc": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", + "dev": true + }, "cheerio": { "version": "1.0.0-rc.12", "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", @@ -5780,6 +5859,12 @@ "which": "^2.0.1" } }, + "crypt": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", + "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", + "dev": true + }, "css-select": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/css-select/-/css-select-5.1.0.tgz", @@ -6665,6 +6750,12 @@ "binary-extensions": "^2.0.0" } }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, "is-docker": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz", @@ -6968,6 +7059,17 @@ } } }, + "md5": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz", + "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==", + "dev": true, + "requires": { + "charenc": "0.0.2", + "crypt": "0.0.2", + "is-buffer": "~1.1.6" + } + }, "mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", @@ -7142,6 +7244,27 @@ } } }, + "mocha-junit-reporter": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/mocha-junit-reporter/-/mocha-junit-reporter-2.2.1.tgz", + "integrity": "sha512-iDn2tlKHn8Vh8o4nCzcUVW4q7iXp7cC4EB78N0cDHIobLymyHNwe0XG8HEHHjc3hJlXm0Vy6zcrxaIhnI2fWmw==", + "dev": true, + "requires": { + "debug": "^4.3.4", + "md5": "^2.3.0", + "mkdirp": "^3.0.0", + "strip-ansi": "^6.0.1", + "xml": "^1.0.1" + }, + "dependencies": { + "mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true + } + } + }, "monaco-page-objects": { "version": "3.12.0", "resolved": "https://registry.npmjs.org/monaco-page-objects/-/monaco-page-objects-3.12.0.tgz", @@ -8231,6 +8354,12 @@ "dev": true, "requires": {} }, + "xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true + }, "xml2js": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz", diff --git a/package.json b/package.json index 04e6d3ae..6c51b474 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/test/suite/index.ts b/src/test/suite/index.ts index 5eb243c9..57857f11 100644 --- a/src/test/suite/index.ts +++ b/src/test/suite/index.ts @@ -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 { - // 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"); diff --git a/src/ui-test/config.ts b/src/ui-test/config.ts index c5f9bd65..3f6495eb 100644 --- a/src/ui-test/config.ts +++ b/src/ui-test/config.ts @@ -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;