aboutsummaryrefslogtreecommitdiff
blob: bcb2d59ceae5da79ce84057a9f8cd4fb9bb59eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Unit tests

on: [push, pull_request]

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version:
        - '3.9'
        - '3.10'
        - '3.11'
        - '3.12-dev'
        - 'pypy-3.9'
        - 'pypy-3.10'

    env:
      # TODO: get this dynamically
      PORTAGE_VERSION: "3.0.57"

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install dependencies
      run: |
        set -xe
        python -VV
        python -m site
        python -m pip install --upgrade pip
        # setuptools needed for 3.12+ because of https://github.com/mesonbuild/meson/issues/7702.
        python -m pip install meson ninja setuptools
    - name: Install portage
      run: |
        mkdir portage
        wget -qO - "https://github.com/gentoo/portage/archive/portage-${PORTAGE_VERSION}.tar.gz" | tar xz -C portage --strip-components=1
        sudo groupadd -g 250 portage
        sudo useradd -g portage -d /var/tmp/portage -s /bin/false -u 250 portage
    - name: Setup gentoo env (required by portage)
      run: |
        sudo mkdir -p /var/db/repos/gentoo /etc/portage /var/cache/distfiles
        wget -qO - "https://github.com/gentoo-mirror/gentoo/archive/master.tar.gz" | sudo tar xz -C /var/db/repos/gentoo --strip-components=1
        sudo wget "https://www.gentoo.org/dtd/metadata.dtd" -O /var/cache/distfiles/metadata.dtd
        sudo wget "https://gitweb.gentoo.org/proj/portage.git/plain/cnf/repos.conf" -O /etc/portage/repos.conf
        sudo ln -s /var/db/repos/gentoo/profiles/default/linux/amd64/17.1/systemd /etc/portage/make.profile
    - name: Test meson install --destdir /tmp/install-root
      run: |
        echo -e "[binaries]\npython = '$(command -v python)'" > /tmp/native.ini
        meson setup --native-file /tmp/native.ini /tmp/build .
        meson install -C /tmp/build --destdir /tmp/install-root
    - name: Run tests for ${{ matrix.python-version }}
      run: |
        export PYTHONPATH="${PWD}/portage/lib"${PYTHONPATH:+:}${PYTHONPATH}
        export PATH="${PWD}/portage/bin":${PATH}
        meson test -C /tmp/build --verbose