From ce5ac627a459b188aa362a76c7a210316952402d Mon Sep 17 00:00:00 2001 From: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Date: Thu, 19 Jan 2023 15:56:49 +0100 Subject: [PATCH 1/3] Allow to specify a profiler app branch Signed-off-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com> --- action/index.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/action/index.js b/action/index.js index c59ba07..82c48b7 100644 --- a/action/index.js +++ b/action/index.js @@ -38,11 +38,15 @@ async function occ(command) { return await cmd(`./occ ${command}`) } -async function ensureApp() { +async function ensureApp(profilerBranch) { let {stdout} = await occ('app:list'); if (!stdout.includes('profiler')) { console.log('installing profiler') - await cmd(`git clone https://github.com/nextcloud/profiler apps/profiler`) + if (profilerBranch) { + await cmd(`git clone -b ` + profilerBranch + ` https://github.com/nextcloud/profiler apps/profiler`) + } else { + await cmd(`git clone https://github.com/nextcloud/profiler apps/profiler`) + } await occ(`app:enable --force profiler`) let {code, stdout} = await occ(`profiler:enable`); if (code !== 0) { @@ -52,8 +56,8 @@ async function ensureApp() { } } -async function run (command, output, compare) { - await ensureApp() +async function run (command, output, compare, profilerBranch) { + await ensureApp(profilerBranch) // warmup await cmd(command) @@ -88,5 +92,5 @@ async function run (command, output, compare) { } } -run(core.getInput('run'), core.getInput('output'), core.getInput('compare-with')) +run(core.getInput('run'), core.getInput('output'), core.getInput('compare-with'), core.getInput('profiler-branch')) .catch(error => core.setFailed(error.message)) From ad9652be34b7c07bdce08fd81c36117e9789b564 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 19 Jan 2023 16:07:18 +0100 Subject: [PATCH 2/3] Rebuild action Signed-off-by: Joas Schilling --- .gitignore | 1 + action/dist/index.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index cc230ff..9814002 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ yarn-error.log /js /.php-cs-fixer.cache /vendor +!/action/dist/index.js diff --git a/action/dist/index.js b/action/dist/index.js index f9ef23d..a3ef9cf 100644 --- a/action/dist/index.js +++ b/action/dist/index.js @@ -2124,11 +2124,15 @@ async function occ(command) { return await cmd(`./occ ${command}`) } -async function ensureApp() { +async function ensureApp(profilerBranch) { let {stdout} = await occ('app:list'); if (!stdout.includes('profiler')) { console.log('installing profiler') - await cmd(`git clone https://github.com/nextcloud/profiler apps/profiler`) + if (profilerBranch) { + await cmd(`git clone -b ` + profilerBranch + ` https://github.com/nextcloud/profiler apps/profiler`) + } else { + await cmd(`git clone https://github.com/nextcloud/profiler apps/profiler`) + } await occ(`app:enable --force profiler`) let {code, stdout} = await occ(`profiler:enable`); if (code !== 0) { @@ -2138,8 +2142,8 @@ async function ensureApp() { } } -async function run (command, output, compare) { - await ensureApp() +async function run (command, output, compare, profilerBranch) { + await ensureApp(profilerBranch) // warmup await cmd(command) @@ -2174,7 +2178,7 @@ async function run (command, output, compare) { } } -run(core.getInput('run'), core.getInput('output'), core.getInput('compare-with')) +run(core.getInput('run'), core.getInput('output'), core.getInput('compare-with'), core.getInput('profiler-branch')) .catch(error => core.setFailed(error.message)) })(); From 781646cf4b2b8f2375cf1a6ef62c08323245adef Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 19 Jan 2023 17:15:20 +0100 Subject: [PATCH 3/3] try to run updated action on pr Signed-off-by: Robin Appelman --- .github/workflows/test-action.yml | 83 +++++++++++++++++++++++++++++++ action/dist/index.js | 6 +-- action/index.js | 6 +-- 3 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/test-action.yml diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml new file mode 100644 index 0000000..45e0cfc --- /dev/null +++ b/.github/workflows/test-action.yml @@ -0,0 +1,83 @@ +name: Test action + +on: + pull_request: + push: + branches: + - main + - master + - stable* + +jobs: + performance-testing: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php-versions: ['8.0'] + + name: performance-${{ matrix.php-versions }} + + steps: + - name: Checkout server + uses: actions/checkout@v2 + with: + repository: nextcloud/server + ref: ${{ matrix.server-versions }} + + - name: Checkout submodules + shell: bash + run: | + auth_header="$(git config --local --get http.https://github.com/.extraheader)" + git submodule sync --recursive + git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1 + + - name: Checkout action + uses: actions/checkout@v2 + with: + path: action + + - name: Set up php ${{ matrix.php-versions }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + tools: phpunit + extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Nextcloud + run: | + mkdir data + ./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password + + php -S localhost:8080 & + - name: Apply blueprint + uses: icewind1991/blueprint@v0.1.2 + with: + blueprint: tests/blueprints/basic.toml + - name: Run first measurements + uses: ./action + with: + run: | + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test + curl -s -u test:test http://localhost:8080/remote.php/dav/files/test/test.txt + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test/many_files + curl -s -u test:test -T README.md http://localhost:8080/remote.php/dav/files/test/new_file.txt + curl -s -u test:test -X DELETE http://localhost:8080/remote.php/dav/files/test/new_file.txt + output: before.json + + - name: Run second measurements + id: compare + uses: ./action + continue-on-error: true + with: + run: | + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test + curl -s -u test:test http://localhost:8080/remote.php/dav/files/test/test.txt + curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test/many_files + curl -s -u test:test -T README.md http://localhost:8080/remote.php/dav/files/test/new_file.txt + curl -s -u test:test -X DELETE http://localhost:8080/remote.php/dav/files/test/new_file.txt + output: after.json + compare-with: before.json diff --git a/action/dist/index.js b/action/dist/index.js index a3ef9cf..537d1df 100644 --- a/action/dist/index.js +++ b/action/dist/index.js @@ -2104,7 +2104,7 @@ function cmd(command) { stdout = stdout + data }) cmd.stderr.on('data', (data) => { - console.error(data); + console.error(data.toString('utf8')); }) cmd.on('error', error => { @@ -2155,7 +2155,7 @@ async function run (command, output, compare, profilerBranch) { console.log('running command') let cmdOut = await cmd(command) - console.log(cmdOut.stdout); + console.log(cmdOut.stdout.toString('utf8')); if (cmdOut.code !== 0) { @@ -2164,7 +2164,7 @@ async function run (command, output, compare, profilerBranch) { console.log('processing result') let {stdout} = await occ('profiler:list'); - console.log(stdout); + console.log(stdout.toString('utf8')); await occ(`profiler:export > ${output}`) diff --git a/action/index.js b/action/index.js index 82c48b7..f30a17f 100644 --- a/action/index.js +++ b/action/index.js @@ -18,7 +18,7 @@ function cmd(command) { stdout = stdout + data }) cmd.stderr.on('data', (data) => { - console.error(data); + console.error(data.toString('utf8')); }) cmd.on('error', error => { @@ -69,7 +69,7 @@ async function run (command, output, compare, profilerBranch) { console.log('running command') let cmdOut = await cmd(command) - console.log(cmdOut.stdout); + console.log(cmdOut.stdout.toString('utf8')); if (cmdOut.code !== 0) { @@ -78,7 +78,7 @@ async function run (command, output, compare, profilerBranch) { console.log('processing result') let {stdout} = await occ('profiler:list'); - console.log(stdout); + console.log(stdout.toString('utf8')); await occ(`profiler:export > ${output}`)