name: flatpak-test
on:
  pull_request

jobs:
  run:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: none
    timeout-minutes: 20
    steps:
      - name: Install required build and test dependencies
        run: |
          sudo apt update
          sudo apt install -y --no-install-recommends autoconf automake elfutils libglib2.0-dev libsystemd-dev xsltproc xmlto flatpak-builder xvfb cockpit-system appstream-util

      - name: Configure flathub remote
        run: flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

      - name: Clone repository
        uses: actions/checkout@v2
        with:
          # need this to also fetch tags
          fetch-depth: 0

      - name: Build and install flatpak
        run: sh -x containers/flatpak/install --user --install-deps-from=flathub

      - name: Validate metainfo
        run: appstream-util validate org.cockpit_project.CockpitClient.metainfo.xml

      - name: Smoke-test the installed flatpak
        run: |
          . /etc/profile.d/flatpak.sh
          xvfb-run dbus-run-session sh -ec '
            containers/flatpak/test/test-ssh
            containers/flatpak/test/test-browser
          '

name: flatpak-test
on:
  pull_request

jobs:
  run:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: none
    timeout-minutes: 20
    steps:
      - name: Install required build and test dependencies
        run: |
          sudo apt update
          sudo apt install -y --no-install-recommends autoconf automake elfutils libglib2.0-dev libsystemd-dev xsltproc xmlto flatpak-builder xvfb cockpit-system appstream-util

      - name: Configure flathub remote
        run: flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

      - name: Clone repository
        uses: actions/checkout@v2
        with:
          # need this to also fetch tags
          fetch-depth: 0

      - name: Build and install flatpak
        run: sh -x containers/flatpak/install --user --install-deps-from=flathub

      - name: Validate metainfo
        run: appstream-util validate org.cockpit_project.CockpitClient.metainfo.xml

      - name: Smoke-test the installed flatpak
        run: |
          . /etc/profile.d/flatpak.sh
          xvfb-run sh -ec '
            dbus-run-session containers/flatpak/test/test-ssh
            dbus-run-session containers/flatpak/test/test-browser
          '

Fix race between flatpak tests
workflows: Fix race between flatpak tests

Even after commit 91854c8cc7b492, test-browser still sometimes tries to
talk to an allegedly existing instance, and then fails on talking into
the void. There are no related processes any more, apparently the
session D-Bus does not recognize the disappeared process fast enough.

Let's avoid that by running each test in its own D-Bus session.

Note: Keep sharing a single Xvfb server, as xvfb-run does not like being
run multiple times in a row without waiting.
