diff --git a/.github/workflows/build-ci.yml b/.github/workflows/build-ci.yml index 4ca1dd5..667604e 100644 --- a/.github/workflows/build-ci.yml +++ b/.github/workflows/build-ci.yml @@ -12,43 +12,19 @@ on: # Allow manual trigger workflow_dispatch: -env: - REGISTRY: ghcr.io - GIT_BRANCH: ${{ github.ref_name }} - jobs: - build-and-push-images: - runs-on: ubuntu-latest - environment: - name: ${{ github.ref_name }} - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract version - id: extract_api_version - run: | - echo "PKG_VERSION=$(python -c 'from fmtm_splitter.__version__ import __version__; print(__version__)')" >> $GITHUB_ENV + extract-vars: + uses: hotosm/gh-workflows/.github/workflows/py_app_version.yml@main + with: + package_name: fmtm_splitter - - name: Build image - uses: docker/build-push-action@v4 - with: - context: . - target: ci - push: true - tags: | - "ghcr.io/hotosm/fmtm-splitter:${{ env.PKG_VERSION }}-ci" - "ghcr.io/hotosm/fmtm-splitter:ci" - build-args: | - PKG_VERSION=${{ env.PKG_VERSION }} + backend-ci-build: + uses: hotosm/gh-workflows/.github/workflows/image_build.yml@main + needs: [extract-vars] + with: + build_target: ci + image_tags: | + "ghcr.io/hotosm/fmtm-splitter:${{ needs.extract-vars.outputs.app_version }}-ci" + "ghcr.io/hotosm/fmtm-splitter:ci" + build_args: | + PKG_VERSION=${{ needs.extract-vars.outputs.app_version }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3f6d5b6..e2c24c2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,43 +6,19 @@ on: # Allow manual trigger workflow_dispatch: -env: - REGISTRY: ghcr.io - GIT_BRANCH: ${{ github.ref_name }} - jobs: - build-and-push-images: - runs-on: ubuntu-latest - environment: - name: ${{ github.ref_name }} - permissions: - contents: read - packages: write - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Log in to the Container registry - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract version - id: extract_api_version - run: | - echo "PKG_VERSION=$(python -c 'from fmtm_splitter.__version__ import __version__; print(__version__)')" >> $GITHUB_ENV + extract-vars: + uses: hotosm/gh-workflows/.github/workflows/py_app_version.yml@main + with: + package_name: fmtm_splitter - - name: Build image - uses: docker/build-push-action@v4 - with: - context: . - target: prod - push: true - tags: | - "ghcr.io/hotosm/fmtm-splitter:${{ env.PKG_VERSION }}" - "ghcr.io/hotosm/fmtm-splitter:latest" - build-args: | - PKG_VERSION=${{ env.PKG_VERSION }} + backend-ci-build: + uses: hotosm/gh-workflows/.github/workflows/image_build.yml@main + needs: [extract-vars] + with: + build_target: prod + image_tags: | + "ghcr.io/hotosm/fmtm-splitter:${{ needs.extract-vars.outputs.app_version }}" + "ghcr.io/hotosm/fmtm-splitter:latest" + build_args: | + PKG_VERSION=${{ needs.extract-vars.outputs.app_version }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 981cf4b..aae6169 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,40 +5,36 @@ on: paths: - docs/** - fmtm_splitter/** + - mkdocs.yml branches: [main] # Allow manual trigger (workflow_dispatch) workflow_dispatch: -permissions: - contents: write - jobs: - publish_docs: - name: Publish Docs + get_cache_key: runs-on: ubuntu-latest + outputs: + cache_key: ${{ steps.set_cache_key.outputs.cache_key }} steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Setup Python - uses: actions/setup-python@v4 - with: - python-version: 3.x - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV + - name: Set cache key + id: set_cache_key + run: echo "cache_key=docs-build-$(date --utc +'%Y-%m-%d_%H:%M:%S')" >> $GITHUB_OUTPUT - - name: Read cache - uses: actions/cache@v3 - with: - key: mkdocs-material-${{ env.cache_id }} - path: .cache - restore-keys: | - mkdocs-material- + build_doxygen: + uses: hotosm/gh-workflows/.github/workflows/doxygen_build.yml@main + needs: [get_cache_key] + with: + cache_paths: | + docs/apidocs + cache_key: ${{ needs.get_cache_key.outputs.cache_key }} - - name: Install PDM - run: | - python3 -m pip install pdm - - - name: Publish - run: | - pdm install -G docs --no-default - pdm run mkdocs gh-deploy --force + publish_docs: + uses: hotosm/gh-workflows/.github/workflows/mkdocs_build.yml@main + needs: + - get_cache_key + - build_doxygen + with: + image: ghcr.io/hotosm/fmtm-splitter:ci + cache_paths: | + docs/apidocs + cache_key: ${{ needs.get_cache_key.outputs.cache_key }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 3245a31..6c69635 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,24 +3,11 @@ name: Publish to PyPi.org on: release: types: [published] - -env: - PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} + # Allow manual trigger (workflow_dispatch) + workflow_dispatch: jobs: publish_to_pypi: - name: Publish to PyPi - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Install PDM - run: | - python3 -m pip install pdm - - - name: Publish - run: | - pdm config repository.pypi.username "__token__" - pdm config repository.pypi.password "${PYPI_TOKEN}" - pdm publish + uses: hotosm/gh-workflows/.github/workflows/pypi_publish.yml@main + secrets: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 726d021..5de8e20 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -5,10 +5,6 @@ on: push: branches: - "*" - paths: - # Workflow is triggered only if code or tests change - - "fmtm_splitter" - - "tests" # Run tests on PR, prior to merge to main & development. pull_request: branches: @@ -19,17 +15,13 @@ on: jobs: test: runs-on: ubuntu-latest + environment: + name: "test" + container: + image: ghcr.io/hotosm/fmtm-splitter:ci steps: - - uses: actions/checkout@v3 - - - name: Start CI Container - run: > - docker run -d --name fmtm_pytest - -v "$GITHUB_WORKSPACE/fmtm_splitter:/home/appuser/.local/lib/python3.10/site-packages/fmtm_splitter" - -v "$GITHUB_WORKSPACE/tests:/data/tests" - ghcr.io/hotosm/fmtm-splitter:ci - sleep infinity - - - name: Run PyTest as appuser - run: docker exec fmtm_pytest gosu appuser pytest + - uses: actions/checkout@v4 + - name: Run pytest + run: | + pytest