Skip to content
Closed
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
49 changes: 49 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,57 @@ jobs:
cat config/config.php
./occ user:list
./occ app:enable --force ${{ env.APP_NAME }}
./occ config:system:set query_log_file --value '/home/runner/work/${{ env.APP_NAME }}/${{ env.APP_NAME }}/query.log'
php -S localhost:8080 &

- name: Run behat
working-directory: apps/${{ env.APP_NAME }}/tests/integration
run: ./run.sh

- name: Query count
if: ${{ matrix.databases == 'mysql' }}
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
let myOutput = ''
let myError = ''

const options = {}
options.listeners = {
stdout: (data) => {
myOutput += data.toString()
},
stderr: (data) => {
myError += data.toString()
}
}
await exec.exec(`/bin/bash -c "cat /home/runner/work/${{ env.APP_NAME }}/${{ env.APP_NAME }}/query.log | wc -l"`, [], options)
msg = myOutput
const queryCount = parseInt(myOutput, 10)

myOutput = ''
await exec.exec('cat', ['/home/runner/work/${{ env.APP_NAME }}/${{ env.APP_NAME }}/apps/${{ env.APP_NAME }}/tests/integration/base-query-count.txt'], options)
const baseCount = parseInt(myOutput, 10)

const absoluteIncrease = queryCount - baseCount
const relativeIncrease = baseCount <= 0 ? 100 : (parseInt((absoluteIncrease / baseCount * 10000), 10) / 100)

if (absoluteIncrease >= 100 || relativeIncrease > 5) {
const comment = `🐢 Performance warning.\nIt looks like the query count of the integration tests increased with this PR.\nDatabase query count is now ` + queryCount + ' was ' + baseCount + ' (+' + relativeIncrease + '%)\nPlease check your code again. If you added a new test this can be expected and the base value in tests/integration/base-query-count.txt can be increased.'
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
}
if (queryCount < 100) {
const comment = `🐈 Performance messuring seems broken. Failed to get query count.`
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
}
1 change: 1 addition & 0 deletions tests/integration/base-query-count.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
61324
1 change: 0 additions & 1 deletion tests/integration/features/bootstrap/ServerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public function getBaseUrl(): string {
}

public function getCookieJar(): CookieJar {
echo $this->currentUser;
return $this->cookieJar;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ if [ -z "$EXECUTOR_NUMBER" ]; then
fi
PORT=$((9090 + $EXECUTOR_NUMBER))
echo $PORT
php -S localhost:$PORT -t $OC_PATH &
php -q -S localhost:$PORT -t $OC_PATH &
PHPPID=$!
echo $PHPPID

export TEST_SERVER_URL="http://localhost:$PORT/ocs/"

vendor/bin/behat $SCENARIO_TO_RUN
vendor/bin/behat --colors $SCENARIO_TO_RUN
RESULT=$?

kill $PHPPID
kill -9 $PHPPID

echo "runsh: Exit code: $RESULT"
exit $RESULT