Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ yarn-error.log
/js
/.php-cs-fixer.cache
/vendor
!/action/dist/index.js
20 changes: 12 additions & 8 deletions action/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -2151,7 +2155,7 @@ async function run (command, output, compare) {
console.log('running command')
let cmdOut = await cmd(command)

console.log(cmdOut.stdout);
console.log(cmdOut.stdout.toString('utf8'));


if (cmdOut.code !== 0) {
Expand All @@ -2160,7 +2164,7 @@ async function run (command, output, compare) {
console.log('processing result')

let {stdout} = await occ('profiler:list');
console.log(stdout);
console.log(stdout.toString('utf8'));

await occ(`profiler:export > ${output}`)

Expand All @@ -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))

})();
Expand Down
20 changes: 12 additions & 8 deletions action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -65,7 +69,7 @@ async function run (command, output, compare) {
console.log('running command')
let cmdOut = await cmd(command)

console.log(cmdOut.stdout);
console.log(cmdOut.stdout.toString('utf8'));


if (cmdOut.code !== 0) {
Expand All @@ -74,7 +78,7 @@ async function run (command, output, compare) {
console.log('processing result')

let {stdout} = await occ('profiler:list');
console.log(stdout);
console.log(stdout.toString('utf8'));

await occ(`profiler:export > ${output}`)

Expand All @@ -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))