diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..c9fd450 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,48 @@ +name: Build and Test + +on: push + +concurrency: + group: "${{ github.ref }}" + cancel-in-progress: true + +env: + NDIP_DOCKER_REPOSITORY: "${{ secrets.NDIP_DOCKER_REPOSITORY }}" + READTHEDOCS_WEBHOOK_URL: "${{ secrets.READTHEDOCS_WEBHOOK_URL }}" + READTHEDOCS_WEBHOOK_SECRET: "${{ secrets.READTHEDOCS_WEBHOOK_SECRET }}" + +jobs: + build-and-test: + runs-on: ubuntu-latest + timeout-minutes: 60 + env: + GIT_STRATEGY: clone + IMAGE_NAME: "${NDIP_DOCKER_REPOSITORY}/${{ github.repository }}" + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 20 + lfs: true + - name: Build + uses: docker/build-push-action@v6 + id: build + with: + file: dockerfiles/Dockerfile + load: true + - name: Run ruff check + run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run ruff check + - name: Run format check + run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run ruff format --check + - name: Run mypy + run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run mypy . + - name: Unit tests + run: docker run --rm ${{ steps.build.outputs.imageid }} poetry run pytest + - name: Run coverage + run: docker run --rm ${{ steps.build.outputs.imageid }} sh -c "poetry run coverage run && poetry run coverage report" + - name: Docs test + run: docker run --rm ${{ steps.build.outputs.imageid }} bash build_docs.sh diff --git a/.github/workflows/nova-common.yml b/.github/workflows/nova-common.yml new file mode 100644 index 0000000..8a7528a --- /dev/null +++ b/.github/workflows/nova-common.yml @@ -0,0 +1,61 @@ +name: Publish Package + +on: workflow_dispatch + +concurrency: + group: "${{ github.ref }}" + cancel-in-progress: true + +env: + PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}" + +jobs: + tag-release: + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: write-all + env: + GIT_STRATEGY: clone + IMAGE_NAME: "${NDIP_DOCKER_REPOSITORY}/${{ github.repository }}" + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 20 + lfs: true + - name: Parse version + run: echo "VERSION=$(cat pyproject.toml | grep "version =" | head -n 1 | awk '{ print $3 }' | tr -d '"')" >> $GITHUB_ENV + - name: Create release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ env.VERSION }} + release_name: ${{ env.VERSION }} + + publish-package: + needs: tag-release + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' + timeout-minutes: 60 + env: + GIT_STRATEGY: clone + IMAGE_NAME: "${NDIP_DOCKER_REPOSITORY}/${{ github.repository }}" + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Checkout repo + uses: actions/checkout@v4 + with: + fetch-depth: 20 + lfs: true + - name: Build + uses: docker/build-push-action@v6 + id: build + with: + file: dockerfiles/Dockerfile + load: true + - name: Publish + run: docker run --rm ${{ steps.build.outputs.imageid }} poetry publish -u __token__ -p ${PYPI_API_TOKEN} diff --git a/dockerfiles/Dockerfile b/dockerfiles/Dockerfile index 60ca2bb..e1231b2 100644 --- a/dockerfiles/Dockerfile +++ b/dockerfiles/Dockerfile @@ -1,6 +1,4 @@ -ARG SOURCE_IMAGE=source - -FROM --platform=amd64 regproxy.ornl.gov/hub_proxy/python:3.10-slim AS source +FROM --platform=amd64 python:3.10-slim AS source # make sure image can run as non-root user ENV POETRY_CACHE_DIR=/poetry/.cache @@ -16,20 +14,3 @@ RUN poetry build --format=wheel RUN chmod og+rwX -R /poetry RUN chmod og+rwX -R /src - - -# This is a workaround that allows the COPY --from location to be defined as a build argument. -# With this, we can reference the built source image from Harbor in our pipelines, while still -# defaulting to using the previous stage for local builds. -FROM $SOURCE_IMAGE as source_image - - - -FROM --platform=amd64 regproxy.ornl.gov/hub_proxy/ubuntu:22.04 AS run - -RUN DEBIAN_FRONTEND="noninteractive" apt-get update && apt-get -y install tzdata -RUN apt-get install -y python3.10 curl -RUN curl -ksS https://bootstrap.pypa.io/get-pip.py | python3.10 - -COPY --from=source_image /src/dist /dist -RUN pip install /dist/*.whl