Skip to content

perf: lazyload some pictures #1562

perf: lazyload some pictures

perf: lazyload some pictures #1562

name: Integration tests on Robot Framework
on:
pull_request:
push:
branches:
- main
workflow_call:
workflow_dispatch:
env:
DOCKER_COMPOSE: docker compose -p gkdev0 -f docker-compose.local.yml --progress plain
APT_INSTALL: sudo apt-get -qq install -qq -o=Dpkg::Use-Pty=0 -y
GK_INSTANCE_COUNT: 3
SHARD_COUNT: 7
PGUSER: geokrety
PGPASSWORD: geokrety
PGDATABASE: geokrety
PGHOST: localhost
PGPORT: 5106
GK_FQDN: localhost
GIT_BRANCH: ${{ github.head_ref || github.ref }}
permissions:
pull-requests: write
jobs:
robot-framework:
if: "${{ ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
SHARD_ID: [1, 2, 3, 4, 5, 6, 7]
env:
SHARD_ID: ${{ matrix.SHARD_ID }}
steps:
- name: Debug
uses: raven-actions/debug@v1
- name: Checkout
uses: actions/checkout@v4
- name: Find node IP
uses: ./.github/actions/find-node-ip/
- name: Start selenoid
uses: ./.github/actions/start-selenoid/
- name: Build website image
uses: ./.github/actions/build-website-image/
with:
prepare-only: true
- name: Pull docker images (background)
shell: bash
run: |
${DOCKER_COMPOSE} pull --ignore-buildable &
- name: Install Robot Framework
run: |
echo "::group::Install RobotFramework"
pip3 install -r tests-qa/requirements.txt &
echo "::endgroup::"
- name: Configure Sentry
shell: bash
run: |
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env
echo "SENTRY_ENV=dev.githubaction" >> .env
- name: Start Postgres
uses: ./.github/actions/start-postgres/
with:
wait-started: false
prepare-only: true
- name: Build website image
uses: ./.github/actions/build-website-image/
- name: Start Docker stack(s)
uses: ./.github/actions/docker-stack-start/
# - name: Install Firefox
# uses: ./.github/actions/install-firefox/
# - name: Install Robot Framework
# uses: ./.github/actions/install-robot-framework/
- name: Run Robot Framework
id: tests-qa
env:
AUTO_REMOTE_URL: true
uses: ./.github/actions/run-robot-framework/
- name: Save docker logs
if: always()
continue-on-error: true
run: |
mkdir docker-logs
for container in nginx website postgres minio pictures-uploader pictures-downloader; do
${DOCKER_COMPOSE} logs ${container} > docker-logs/${container}.log
done
- name: Kill the docker stack(s)
if: always()
continue-on-error: true
run: |
make kill DOCKER_COMPOSE_PARAMS="-s SIGKILL" &
- name: Upload docker logs
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: docker-logs-${{ env.SHARD_ID }}
path: |
docker-logs/
- name: Upload results
if: ${{ always() && steps.tests-qa.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: test-results-${{ env.SHARD_ID }}
path: |
tests-qa/docs/${{ env.GIT_BRANCH }}/
!tests-qa/docs/${{ env.GIT_BRANCH }}/pabot_results
report-assemble:
needs: [robot-framework, phpunit-tests]
if: "${{ always() && ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
pattern: test-results-*
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: test-unit
- name: Checkout visual_images baseline
uses: actions/checkout@v4
with:
path: website
sparse-checkout: tests-qa/visual_images
- name: Move visual_images folder
continue-on-error: true
run: |
mkdir visual_images || true
mv website/tests-qa/visual_images visual_images/baseline
rm -fr website
- name: Install Robot Framework
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "::group::Obtain requirements.txt"
gh api \
/repos/${GITHUB_REPOSITORY}/contents/tests-qa/requirements.txt?ref=${{ github.ref }} \
--jq '.content' | base64 -d > /tmp/requirements.txt
echo "::endgroup::"
pip3 install -r /tmp/requirements.txt
- name: Assemble reports
id: assemble-report
continue-on-error: true
run: |
ret=0
echo "::group::list files before"
pwd
find . -type f
echo "::endgroup::"
echo
# Robot Framework report
echo "::group::Robot Framework report"
rebot --nostatusrc --merge output-*.xml || ret=$?
echo "::endgroup::"
echo
# merge xml files
echo "::group::merge xml files"
/usr/bin/env python3 - output-*.xml >> output.xml <<EOF
#!/usr/bin/env python3
import sys
from xml.etree import ElementTree
def run(files):
first = None
for filename in files:
data = ElementTree.parse(filename).getroot()
if first is None:
first = data
else:
first.extend(data)
if first is not None:
print(ElementTree.tostring(first, encoding='unicode'))
if __name__ == "__main__":
run(sys.argv[1:])
EOF
echo "::endgroup::"
echo
echo "::group::List all xml files"
ls -l *.xml
echo "::endgroup::"
# Robot Eyes report
echo "::group::Robot Eyes report"
reportgen \
--baseline=visual_images/baseline \
--results=. || ret=$?
echo "::endgroup::"
echo
echo "::group::Fix images path"
sed -i 's@\.\./@@g' visualReport.html || ret=$?
echo "::endgroup::"
echo
# Add visualReport.html link into report.html
echo "::group::Add visualReport.html link into report.html"
anchor='\(<td><a href="${$item.logURL}">${$item.logURL}\)</a></td>'
link='<tr><th>Visual Report:</th><td><a href="visualReport.html">visualReport.html</a></td></tr>'
sed -i "s@${anchor}@\1${link}@" report.html || ret=$?
echo "::endgroup::"
echo
echo
echo "::group::list files after"
pwd
find . -type f
echo "::endgroup::"
exit "${ret}"
- name: Upload report to job artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: test-report
path: .
- name: Deploy GH pages
id: deploy-pages
env:
QA_TEST_DEPLOY_KEY: ${{ secrets.QA_TEST_DEPLOY_KEY || '' }}
if: always() && env.QA_TEST_DEPLOY_KEY != '' && steps.assemble-report.conclusion == 'success'
uses: peaceiris/actions-gh-pages@v4
with:
keep_files: true
deploy_key: ${{ secrets.QA_TEST_DEPLOY_KEY }}
external_repository: geokrety/geokrety-website-qa
publish_branch: gh-pages
publish_dir: .
destination_dir: ${{ env.GIT_BRANCH }}
user_name: geokrety-bot
user_email: [email protected]
commit_message: "docs: Update QA tests results"
- name: Show report URL
if: always() && env.QA_TEST_DEPLOY_KEY != '' && steps.deploy-pages.outcome == 'success'
env:
QA_TEST_DEPLOY_KEY: ${{ secrets.QA_TEST_DEPLOY_KEY || '' }}
run: |
report_url="https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/report.html"
visual_report_url="https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/visualReport.html"
unit_report_url="https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/test-unit/test-unit-report.html"
echo "${report_url}"
echo "${visual_report_url}"
echo "${unit_report_url}"
echo '### Robot Framework reports' >> $GITHUB_STEP_SUMMARY
echo "* [report](${report_url})" >> $GITHUB_STEP_SUMMARY
echo "* [visualReport](${visual_report_url})" >> $GITHUB_STEP_SUMMARY
echo "* [PHPUnit](${unit_report_url})" >> $GITHUB_STEP_SUMMARY
- name: Post report URL in PR
env:
QA_TEST_DEPLOY_KEY: ${{ secrets.QA_TEST_DEPLOY_KEY || '' }}
if: env.QA_TEST_DEPLOY_KEY != '' && github.event_name == 'pull_request' && steps.deploy-pages.outcome == 'success'
uses: thollander/actions-comment-pull-request@v2
with:
message: |
### Robot Framework reports
* [report](https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/report.html)
* [visualReport](https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/visualReport.html)
* [PHPUnit](https://geokrety.github.io/geokrety-website-qa/${{ env.GIT_BRANCH }}/test-unit/test-unit-report.html)
comment_tag: rbfr
reactions: eyes, rocket
database-tests:
if: "${{ ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
env:
GK_INSTANCE_COUNT: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Find node IP
uses: ./.github/actions/find-node-ip/
- name: Pull docker images (background)
shell: bash
run: |
${DOCKER_COMPOSE} pull --ignore-buildable &
- name: Start Postgres
uses: ./.github/actions/start-postgres/
- name: Install PostGis data
uses: ./.github/actions/install-postgis-data/
- name: Install tools
run: |
echo "::group::Install httping"
sudo apt-get update
${APT_INSTALL} httping
echo "::endgroup::"
- name: Build website image
uses: ./.github/actions/build-website-image/
- name: Start Docker stack(s)
uses: ./.github/actions/docker-stack-start/
- name: Run database tests
uses: ./.github/actions/run-pgtap/
phpunit-tests:
if: "${{ ! (contains(github.event.head_commit.message, 'skip tests-qa') || github.event.pull_request.title == 'translation: New Crowdin updates') }}"
runs-on: ubuntu-latest
env:
GK_INSTANCE_COUNT: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pull docker images (background)
shell: bash
run: |
${DOCKER_COMPOSE} pull --ignore-buildable &
- name: Start Postgres
uses: ./.github/actions/start-postgres/
- name: Install PostGis data
uses: ./.github/actions/install-postgis-data/
- name: Install tools
run: |
echo "::group::Install httping"
sudo apt-get update
${APT_INSTALL} httping
echo "::endgroup::"
- name: Build website image
uses: ./.github/actions/build-website-image/
- name: Start Docker stack(s)
uses: ./.github/actions/docker-stack-start/
- name: Run PHPUnit tests
id: tests-unit
uses: ./.github/actions/run-phpunit/
- name: Upload results
if: ${{ always() && steps.tests-unit.outcome != 'skipped' }}
uses: actions/upload-artifact@v4
with:
name: test-unit
path: |
test-unit-report.html