API Server #235
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # TODO: check formatting | |
| # TODO: lock files on all platforms | |
| # TODO: test with all supported python versions | |
| name: CI | |
| on: | |
| merge_group: | |
| push: | |
| pull_request: | |
| workflow_dispatch: | |
| inputs: | |
| publish_testpypi: | |
| description: 'Publish to TestPyPI' | |
| required: true | |
| type: boolean | |
| default: false | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| # python version for dev workspace | |
| DEV_WORKSPACE_PYTHON_VERSION: '3.13' | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 1 | |
| matrix: | |
| os: [ubuntu-24.04, macos-15, windows-2022] | |
| include: | |
| - os: ubuntu-24.04 | |
| name: Linux | |
| - os: macos-15 | |
| name: macOS | |
| - os: windows-2022 | |
| name: Windows | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| # setuptools-scm uses tags to get the current version, fetch history and tags | |
| # to get correct version | |
| fetch-depth: 0 | |
| fetch-tags: 'true' | |
| - name: Set up Python ${{ env.DEV_WORKSPACE_PYTHON_VERSION }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.DEV_WORKSPACE_PYTHON_VERSION }} | |
| - name: Install dependencies | |
| run: | | |
| python -m venv .venvs/dev_workspace | |
| source .venvs/dev_workspace/bin/activate | |
| python -m pip install --upgrade pip==25.3 | |
| # split installation into 2 steps: first internal preset because it is not | |
| # published as pypi package, so pip will fail to resolve it in dev_workspace | |
| # group and only then other dependencies | |
| python -m pip install -e ./finecode_dev_common_preset | |
| python -m pip install --group="dev_workspace" -e . -e ./finecode_extension_runner | |
| python -m finecode prepare-envs | |
| shell: bash | |
| - name: Lint | |
| run: | | |
| source .venvs/dev_workspace/bin/activate | |
| python -m finecode run lint | |
| shell: bash | |
| - name: Build artifacts | |
| id: build | |
| if: runner.os == 'Linux' | |
| run: | | |
| source .venvs/dev_workspace/bin/activate | |
| python -m finecode run build_artifact | |
| shell: bash | |
| - name: Run unit tests | |
| if: ${{ !cancelled() }} | |
| run: | | |
| source .venvs/dev_workspace/bin/activate | |
| # TODO: test with all supported python versions | |
| python -m finecode run run_tests | |
| shell: bash | |
| - name: Publish to TestPyPI and verify | |
| if: runner.os == 'Linux' && github.event_name == 'workflow_dispatch' && inputs.publish_testpypi | |
| env: | |
| FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__REPOSITORIES: '[{"name": "testpypi", "url": "https://test.pypi.org/"}]' | |
| FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__CREDENTIALS_BY_REPOSITORY: '{"testpypi": {"username": "${{ secrets.TESTPYPI_USERNAME }}", "password": "${{ secrets.TESTPYPI_PASSWORD }}"}}' | |
| run: | | |
| source .venvs/dev_workspace/bin/activate | |
| python -m finecode run \ | |
| --map-payload-fields="src-artifact-def-path,dist-artifact-paths" \ | |
| publish_and_verify_artifact \ | |
| --src-artifact-def-path="build_artifact.src_artifact_def_path" \ | |
| --dist-artifact-paths="build_artifact.build_output_paths" | |
| shell: bash | |
| - name: Publish to PyPI and verify | |
| if: runner.os == 'Linux' && startsWith(github.ref, 'refs/tags/') | |
| env: | |
| FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__REPOSITORIES: '[{"name": "pypi", "url": "https://pypi.org/"}]' | |
| FINECODE_CONFIG_PUBLISH_AND_VERIFY_ARTIFACT__INIT_REPOSITORY_PROVIDER__CREDENTIALS_BY_REPOSITORY: '{"pypi": {"username": "${{ secrets.PYPI_USERNAME }}", "password": "${{ secrets.PYPI_PASSWORD }}"}}' | |
| run: | | |
| # TODO: make sure git tag exists (for manual trigger) | |
| source .venvs/dev_workspace/bin/activate | |
| python -m finecode run \ | |
| --map-payload-fields="src-artifact-def-path,dist-artifact-paths" \ | |
| publish_and_verify_artifact \ | |
| --src-artifact-def-path="build_artifact.src_artifact_def_path" \ | |
| --dist-artifact-paths="build_artifact.build_output_paths" | |
| shell: bash | |
| # TODO: try to replace by finecode action | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v4 | |
| if: runner.os == 'Linux' | |
| with: | |
| name: python-package-distributions | |
| path: dist/ |