diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..862c5b8 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,50 @@ +name: Build and push docker image + +on: + push: + branches: + - main + +jobs: + build-and-push: + name: Build and push docker image + runs-on: ubuntu-latest + + steps: + - name: checkout code + uses: actions/checkout@v4 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: install poetry + run: | + python -m pip install --no-cache-dir poetry==1.8 supervisor + + - name: set up docker + run: | + make gha-setup + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Clean previous builds + run: rm -rf dist/*.whl + + - name: Build with Poetry + run: poetry build + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 0000000..a0a62f4 --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,35 @@ +name: Build and test + +on: + pull_request: + push: + branches: [main] + +jobs: + build-and-test: + name: pytest + runs-on: ubuntu-latest + + concurrency: + group: platformics-build-and-test-${{ github.ref }} + cancel-in-progress: true + + steps: + - name: checkout code + uses: actions/checkout@v4 + - name: set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.11' + - name: install poetry + run: | + python -m pip install --no-cache-dir poetry==1.8 supervisor + + - name: set up docker + run: make gha-setup + + - name: Build docker image + run: make build + + - name: run tests + run: make test diff --git a/.gitignore b/.gitignore index 76f6269..a2d4326 100644 --- a/.gitignore +++ b/.gitignore @@ -254,3 +254,6 @@ test_app/database/* test_app/cerbos/* test_app/support/* test_app/test_infra/* + +# temp files +/tmp/* diff --git a/docker-compose.yml b/docker-compose.yml index 5324f43..b270fb5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ services: platformics: - image: "platformics" + image: ghcr.io/chanzuckerberg/platformics:latest build: context: "." dockerfile: "Dockerfile" diff --git a/test_app/Dockerfile b/test_app/Dockerfile index 8b2dbe8..de1a8b3 100644 --- a/test_app/Dockerfile +++ b/test_app/Dockerfile @@ -1,4 +1,4 @@ -FROM platformics +FROM ghcr.io/chanzuckerberg/platformics:latest RUN apt update && \ apt install -y nginx nginx-extras && \ diff --git a/test_app/Makefile b/test_app/Makefile index 3fc5603..03c50bd 100644 --- a/test_app/Makefile +++ b/test_app/Makefile @@ -46,6 +46,7 @@ init: $(docker_compose_run) $(APP_CONTAINER) sh -c 'strawberry export-schema main:schema > /app/api/schema.graphql' sleep 5 # wait for the app to reload after having files updated. docker compose up -d + sleep 5 docker compose exec $(APP_CONTAINER) python3 -m sgqlc.introspection --exclude-deprecated --exclude-description http://localhost:9009/graphql api/schema.json .PHONY: clean