|
| 1 | +name: Test-Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['master'] |
| 6 | + tags: |
| 7 | + - 'v*' # only publish when pushing version tags (e.g., v1.0.0) |
| 8 | + pull_request: |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + test: |
| 13 | + runs-on: ${{ matrix.os }} |
| 14 | + timeout-minutes: 45 |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + # test for: |
| 18 | + # * oldest supported version |
| 19 | + # * latest available Python version |
| 20 | + python-version: ['3.14'] |
| 21 | + # * Linux using ubuntu-latest |
| 22 | + # * Windows using windows-latest |
| 23 | + os: ['windows-latest'] |
| 24 | + # * OM stable - latest stable version |
| 25 | + # * OM nightly - latest nightly build |
| 26 | + omc-version: ['nightly'] |
| 27 | + |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v6 |
| 30 | + |
| 31 | + - name: Set up Python ${{ matrix.python-version }} |
| 32 | + uses: actions/setup-python@v6 |
| 33 | + with: |
| 34 | + python-version: ${{ matrix.python-version }} |
| 35 | + architecture: 'x64' |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip build setuptools wheel twine |
| 40 | + pip install . pytest pytest-md pytest-emoji pre-commit |
| 41 | +
|
| 42 | + - name: Set timezone |
| 43 | + uses: szenius/set-timezone@v2.0 |
| 44 | + with: |
| 45 | + timezoneLinux: 'Europe/Berlin' |
| 46 | + |
| 47 | + - name: Run pre-commit linters |
| 48 | + run: 'pre-commit run --all-files' |
| 49 | + |
| 50 | + - name: "Set up OpenModelica Compiler" |
| 51 | + uses: OpenModelica/setup-openmodelica@v1.0.7 |
| 52 | + with: |
| 53 | + version: ${{ matrix.omc-version }} |
| 54 | + packages: | |
| 55 | + omc |
| 56 | + libraries: | |
| 57 | + 'Modelica 4.0.0' |
| 58 | + - run: "omc --version" |
| 59 | + |
| 60 | + - name: Pull OpenModelica docker image |
| 61 | + if: runner.os != 'Windows' |
| 62 | + run: docker pull openmodelica/openmodelica:v1.25.0-minimal |
| 63 | + |
| 64 | + - name: Build wheel and sdist packages |
| 65 | + run: python -m build --wheel --sdist --outdir dist |
| 66 | + |
| 67 | + - name: Check twine |
| 68 | + run: python -m twine check dist/* |
| 69 | + |
| 70 | + - name: Run pytest |
| 71 | + uses: pavelzw/pytest-action@v2 |
| 72 | + with: |
| 73 | + verbose: true |
| 74 | + emoji: true |
| 75 | + job-summary: true |
| 76 | + custom-arguments: '-v ./tests' |
| 77 | + click-to-expand: true |
| 78 | + report-title: 'Test Report' |
| 79 | + |
| 80 | + - name: Run pytest based on v4.0.0 compatibility layer |
| 81 | + uses: pavelzw/pytest-action@v2 |
| 82 | + with: |
| 83 | + verbose: true |
| 84 | + emoji: true |
| 85 | + job-summary: true |
| 86 | + custom-arguments: '-v ./tests_v400' |
| 87 | + click-to-expand: true |
| 88 | + report-title: 'Test Report (v4.0.0 compatibility layer)' |
| 89 | + |
| 90 | + Publish: |
| 91 | + name: Publish to PyPI |
| 92 | + runs-on: ${{ matrix.os }} |
| 93 | + needs: test |
| 94 | + strategy: |
| 95 | + matrix: |
| 96 | + python-version: ['3.10'] |
| 97 | + os: ['ubuntu-latest'] |
| 98 | + if: startsWith(github.ref, 'refs/tags/') |
| 99 | + steps: |
| 100 | + - uses: actions/checkout@v6 |
| 101 | + |
| 102 | + - name: Set up Python ${{ matrix.python-version }} |
| 103 | + uses: actions/setup-python@v6 |
| 104 | + with: |
| 105 | + python-version: ${{ matrix.python-version }} |
| 106 | + architecture: 'x64' |
| 107 | + |
| 108 | + - name: Install dependencies |
| 109 | + run: | |
| 110 | + python -m pip install --upgrade pip build setuptools wheel twine |
| 111 | +
|
| 112 | + - name: Build wheel and sdist packages |
| 113 | + run: python -m build --wheel --sdist --outdir dist |
| 114 | + |
| 115 | + - name: Publish wheel and sdist packages to PyPI |
| 116 | + env: |
| 117 | + TWINE_USERNAME: __token__ |
| 118 | + TWINE_PASSWORD: ${{ secrets.PYPI_OMPYTHON_API_TOKEN }} |
| 119 | + run: | |
| 120 | + python -m twine upload dist/* --skip-existing |
0 commit comments