-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from eclipsesource/add-performance-measurement-…
…task Add performance measurement task
- Loading branch information
Showing
10 changed files
with
605 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Performance | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
schedule: | ||
- cron: "0 5 * * *" # Runs every day at 5am: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events-schedule | ||
|
||
jobs: | ||
build: | ||
name: Performance benchmark on ubuntu-latest with Node.js 16.x | ||
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 60 | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js "16.x" | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.x" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: Use Python 3.x | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.x" | ||
|
||
- name: Build | ||
shell: bash | ||
run: yarn | ||
|
||
- name: Checkout Theia | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: eclipse-theia/theia | ||
path: ./theia | ||
|
||
- name: Build Theia | ||
shell: bash | ||
working-directory: ./theia | ||
run: | | ||
yarn --skip-integrity-check --network-timeout 100000 | ||
yarn browser build | ||
env: | ||
NODE_OPTIONS: --max_old_space_size=4096 | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://github.com/microsoft/vscode-ripgrep/issues/9 | ||
|
||
- name: Run Theia | ||
shell: bash | ||
working-directory: ./theia | ||
run: yarn browser start & | ||
|
||
- name: Run Performance Measurement | ||
uses: GabrielBB/xvfb-action@v1 | ||
with: | ||
run: yarn performance | ||
|
||
- name: Get History | ||
uses: actions/checkout@v2 | ||
if: always() && github.ref == 'refs/heads/main' | ||
continue-on-error: true | ||
with: | ||
ref: gh-pages | ||
path: gh-pages | ||
|
||
- name: Prepare Report | ||
if: always() && github.ref == 'refs/heads/main' | ||
shell: bash | ||
run: yarn performance-report | ||
|
||
- name: Publish Report | ||
if: always() && github.ref == 'refs/heads/main' | ||
uses: peaceiris/actions-gh-pages@v3 | ||
env: | ||
PERSONAL_TOKEN: ${{ secrets.TOKEN }} | ||
PUBLISH_DIR: ./public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,6 @@ | |
node_modules | ||
allure-results | ||
test-results | ||
performance-metrics | ||
public | ||
gh-pages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { PlaywrightTestConfig } from '@playwright/test'; | ||
import { MetricsFetchConfig } from '../scripts/fetch-metrics'; | ||
|
||
const performanceConfig: PlaywrightTestConfig = { | ||
testDir: '../lib/tests', | ||
testMatch: ['**/*.performance.js'], | ||
globalTeardown: require.resolve('../scripts/fetch-metrics.ts'), | ||
workers: 1, | ||
timeout: 60 * 1000, | ||
use: { | ||
baseURL: 'http://localhost:3000', | ||
browserName: 'chromium', | ||
viewport: { width: 1920, height: 1080 } | ||
}, | ||
metadata: { | ||
// custom metadata to configure /scripts/ci-global-tear-down.ts | ||
performanceMetrics: <MetricsFetchConfig>{ | ||
metricsEndpoint: 'http://localhost:3000/metrics', | ||
outputFileNamePrefix: '', | ||
outputFileNamePostfix: '.txt', | ||
outputFilePath: 'performance-metrics' | ||
} | ||
}, | ||
preserveOutput: 'failures-only', | ||
reporter: [ | ||
['list'] | ||
], | ||
}; | ||
|
||
export default performanceConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// ***************************************************************************** | ||
// Copyright (C) 2023 STMicroelectronics and others. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License v. 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0. | ||
// | ||
// This Source Code may also be made available under the following Secondary | ||
// Licenses when the conditions for such availability set forth in the Eclipse | ||
// Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
// with the GNU Classpath Exception which is available at | ||
// https://www.gnu.org/software/classpath/license.html. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
// ***************************************************************************** | ||
|
||
import { type FullConfig } from '@playwright/test'; | ||
import * as fs from 'fs-extra'; | ||
import fetch from 'node-fetch'; | ||
|
||
async function fetchMetrics(config: FullConfig) { | ||
await fetchPerformanceMetrics(config.metadata.performanceMetrics, config.metadata.totalTime); | ||
} | ||
|
||
export default fetchMetrics; | ||
|
||
export interface MetricsFetchConfig { | ||
metricsEndpoint: string; | ||
outputFileNamePrefix: string; | ||
outputFileNamePostfix: string; | ||
outputFilePath: string; | ||
} | ||
|
||
export async function fetchPerformanceMetrics({ | ||
metricsEndpoint, | ||
outputFileNamePrefix, | ||
outputFileNamePostfix, | ||
outputFilePath }: MetricsFetchConfig, | ||
totalTime?: string | ||
) { | ||
const now = new Date(); | ||
const dateString = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()}`; | ||
const timeString = `${now.getHours()}-${now.getMinutes()}-${now.getSeconds()}`; | ||
const timestamp = `${dateString}T${timeString}`; | ||
const fileName = outputFileNamePrefix + timestamp + outputFileNamePostfix; | ||
const targetFile = `${outputFilePath}/${fileName}`; | ||
|
||
fs.ensureDirSync(outputFilePath); | ||
if (fs.existsSync(targetFile)) { | ||
console.warn('Output file already exists, deleting it...'); | ||
fs.rmSync(targetFile); | ||
} | ||
|
||
try { | ||
const response = await fetch(metricsEndpoint); | ||
let data = await response.text(); | ||
if (totalTime) { | ||
data += ` | ||
playwright_total_time ${totalTime}`; | ||
} | ||
|
||
fs.writeFileSync(targetFile, data); | ||
} catch (error) { | ||
console.error('Error while fetching metrics', error); | ||
process.exit(-1); | ||
} | ||
} | ||
|
Oops, something went wrong.