1on:
2  push:
3    branches:
4      - main
5      - v*-branch
6  pull_request:
7
8name: imgtool
9
10concurrency:
11  group: imgtool-${{ github.event.pull_request.number || github.ref }}
12  cancel-in-progress: true
13
14jobs:
15  test:
16    runs-on: ubuntu-latest
17    strategy:
18      matrix:
19        python-version: ["3.x", "pypy3.9"]
20    steps:
21    - uses: actions/checkout@v4
22    - name: Set up Python ${{ matrix.python-version }}
23      uses: actions/setup-python@v4
24      with:
25        python-version: ${{ matrix.python-version }}
26        cache: 'pipenv'
27        cache-dependency-path: |
28          scripts/setup.py
29    - name: Install dependencies
30      run: |
31        pip install --user pipenv
32    - name: Run tests
33      run: |
34        cd scripts
35        pipenv run pip install pytest -e .
36        pipenv run pytest --junitxml=../junit/pytest-results-${{ matrix.python-version }}.xml
37    - name: Upload test results
38      uses: actions/upload-artifact@v3
39      if: always()
40      with:
41        name: pytest-results-${{ matrix.python-version }}
42        path: |
43          junit/pytest-results-${{ matrix.python-version }}*.xml
44        if-no-files-found: ignore
45  environment:
46    if: ${{ github.event_name == 'push' }}
47    runs-on: ubuntu-latest
48    steps:
49    - uses: actions/checkout@v2
50      with:
51        fetch-depth: 0
52    - name: Cache pip
53      uses: actions/cache@v1
54      with:
55        path: ~/.cache/pip
56        key: ${{ runner.os }}-pip
57    - name: Install packages
58      run: |
59        export PATH="$HOME/.local/bin:$PATH"
60        ./ci/imgtool_install.sh
61    - name: Publish
62      env:
63        TWINE_TOKEN: ${{ secrets.TWINE_TOKEN }}
64      run: |
65        export PATH="$HOME/.local/bin:$PATH"
66        ./ci/imgtool_run.sh
67