Updated the workflow #132
This file contains 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
name: Docker API Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build-and-publish: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.12"] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest numba | |
if [ -f "requirements.txt" ]; then pip install -r requirements.txt; fi | |
- name: Build Docker image | |
run: docker build -t mytestimage . | |
- name: Run Docker container | |
run: docker run -d --name mytestcontainer -p 7637:7637 mytestimage | |
- name: Run tests | |
run: pytest test/docker_tests/ | |
- name: Login to Docker Hub | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: docker/login-action@v1 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push Docker images | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
tags: birchkwok/lynsedb:latest | |
platforms: linux/amd64, linux/arm64 | |
- name: Cleanup | |
if: always() | |
run: docker stop mytestcontainer && docker rm mytestcontainer |