<commit_before>name: Portal CI

on: [push, pull_request]

env:
  DEBIAN_FRONTEND: noninteractive
  TESTS_TIMEOUT: 5 # in minutes

jobs:
  check:
    name: Ubuntu 21.10 build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ['gcc', 'clang']

    env:
      UBUNTU_VERSION: impish
      CC: ${{ matrix.compiler }}
      CFLAGS: -fsanitize=undefined -fsanitize-undefined-trap-on-error -fsanitize=address -Wp,-D_FORTIFY_SOURCE=2
      BUILD_CONTAINER: ${{ matrix.compiler }}-build-container
      RUN_CMD: docker exec -t -w /src -e TEST_IN_CI -e ASAN_OPTIONS -e G_MESSAGES_DEBUG -e XDG_DATA_DIRS ${{ matrix.compiler }}-build-container
      AS_USER: runuser -u tester --

    steps:
    - name: Prepare container
      run: |
        docker run --name $BUILD_CONTAINER \
          --tty --device /dev/fuse --cap-add SYS_ADMIN \
          --security-opt apparmor:unconfined \
          -v $(pwd):/src \
          -e DEBIAN_FRONTEND \
          -e DEBCONF_NONINTERACTIVE_SEEN=true \
          -e TERM=dumb \
          -e CC -e CFLAGS \
          -d ubuntu:$UBUNTU_VERSION sleep infinity

    - name: Install dependencies
      run: |
        $RUN_CMD apt-get update
        $RUN_CMD apt-get upgrade -y
        $RUN_CMD apt-get install -y --no-install-recommends \
          make automake autoconf libtool gettext autopoint ${{ matrix.compiler }} \
          gtk-doc-tools shared-mime-info desktop-file-utils gnome-desktop-testing xmlto fuse \
          libglib2.0-dev libgeoclue-2-dev libjson-glib-dev libfontconfig1-dev libfuse-dev libportal-dev libpipewire-0.3-dev

    - name: Check out xdg-desktop-portal
      uses: actions/checkout@v2

    - name: Setup test user
      run: |
        $RUN_CMD adduser --disabled-password --gecos "" tester
        $RUN_CMD chown tester:tester . -R

    - name: Configure xdg-desktop-portal
      run: $RUN_CMD $AS_USER ./autogen.sh --disable-dependency-tracking --enable-installed-tests

    - name: Build xdg-desktop-portal
      run: $RUN_CMD $AS_USER make -j $(getconf _NPROCESSORS_ONLN)

    - name: Run xdg-desktop-portal tests
      # TODO: Build with -j (currently ends up with hangs in the tests)
      run: $RUN_CMD $AS_USER timeout ${TESTS_TIMEOUT}m make check
      env:
        TEST_IN_CI: 1
        ASAN_OPTIONS: detect_leaks=0 # Right now we're not fully clean, but this gets us use-after-free etc

    - name: Install xdg-desktop-portal
      run: $RUN_CMD make install

    - name: Run xdg-desktop-portal installed-tests
      run: |
        test -n "$($RUN_CMD $AS_USER gnome-desktop-testing-runner -l xdg-desktop-portal)"
        $RUN_CMD $AS_USER \
          env TEST_INSTALLED_IN_CI=1 XDG_DATA_DIRS=/src/tests/share/:$XDG_DATA_DIRS \<commit_msg>CI: Use G_MESSAGES_DEBUG=all in all the tests<commit_after>name: Portal CI

on: [push, pull_request]

env:
  DEBIAN_FRONTEND: noninteractive
  TESTS_TIMEOUT: 5 # in minutes

jobs:
  check:
    name: Ubuntu 21.10 build
    runs-on: ubuntu-latest
    strategy:
      matrix:
        compiler: ['gcc', 'clang']

    env:
      UBUNTU_VERSION: impish
      CC: ${{ matrix.compiler }}
      CFLAGS: -fsanitize=undefined -fsanitize-undefined-trap-on-error -fsanitize=address -Wp,-D_FORTIFY_SOURCE=2
      BUILD_CONTAINER: ${{ matrix.compiler }}-build-container
      RUN_CMD: docker exec -t -w /src -e TEST_IN_CI -e ASAN_OPTIONS -e G_MESSAGES_DEBUG -e XDG_DATA_DIRS ${{ matrix.compiler }}-build-container
      AS_USER: runuser -u tester --

    steps:
    - name: Prepare container
      run: |
        docker run --name $BUILD_CONTAINER \
          --tty --device /dev/fuse --cap-add SYS_ADMIN \
          --security-opt apparmor:unconfined \
          -v $(pwd):/src \
          -e DEBIAN_FRONTEND \
          -e DEBCONF_NONINTERACTIVE_SEEN=true \
          -e TERM=dumb \
          -e CC -e CFLAGS \
          -d ubuntu:$UBUNTU_VERSION sleep infinity

    - name: Install dependencies
      run: |
        $RUN_CMD apt-get update
        $RUN_CMD apt-get upgrade -y
        $RUN_CMD apt-get install -y --no-install-recommends \
          make automake autoconf libtool gettext autopoint ${{ matrix.compiler }} \
          gtk-doc-tools shared-mime-info desktop-file-utils gnome-desktop-testing xmlto fuse \
          libglib2.0-dev libgeoclue-2-dev libjson-glib-dev libfontconfig1-dev libfuse-dev libportal-dev libpipewire-0.3-dev

    - name: Check out xdg-desktop-portal
      uses: actions/checkout@v2

    - name: Setup test user
      run: |
        $RUN_CMD adduser --disabled-password --gecos "" tester
        $RUN_CMD chown tester:tester . -R

    - name: Configure xdg-desktop-portal
      run: $RUN_CMD $AS_USER ./autogen.sh --disable-dependency-tracking --enable-installed-tests

    - name: Build xdg-desktop-portal
      run: $RUN_CMD $AS_USER make -j $(getconf _NPROCESSORS_ONLN)

    - name: Run xdg-desktop-portal tests
      # TODO: Build with -j (currently ends up with hangs in the tests)
      run: $RUN_CMD $AS_USER timeout ${TESTS_TIMEOUT}m make check
      env:
        TEST_IN_CI: 1
        G_MESSAGES_DEBUG: all
        ASAN_OPTIONS: detect_leaks=0 # Right now we're not fully clean, but this gets us use-after-free etc

    - name: Install xdg-desktop-portal
      run: $RUN_CMD make install

    - name: Run xdg-desktop-portal installed-tests
      run: |
        test -n "$($RUN_CMD $AS_USER gnome-desktop-testing-runner -l xdg-desktop-portal)"
        $RUN_CMD $AS_USER \
          env TEST_INSTALLED_IN_CI=1 XDG_DATA_DIRS=/src/tests/share/:$XDG_DATA_DIRS \
{'fraction_non_alphanumeric': 0.10439360929557008, 'fraction_numerical': 0.005809731299927378, 'mean_word_length': 2.3735456215554196, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7431004', 'n_tokens_mistral': 1991, 'n_tokens_neox': 1863, 'n_words': 468}