Build and test containers #51
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: Build and test containers | |
on: | |
push: | |
pull_request: | |
branches: | |
- master | |
schedule: | |
# Every Sunday at 8:05 UTC | |
- cron: "5 8 * * 0" | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [310, 311, 312] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Spin up container | |
run: | | |
sed -i "s/PYTHON_VERSION=.*/PYTHON_VERSION=${{ matrix.python-version }}/" '.env' | |
sed -i 's/PORT=.*/PORT=5002/' '.env' | |
echo "Building container for Python ${{ matrix.python-version }}." | |
cat | |
docker compose up -d | |
- name: Wait and check the health of the container | |
run: | | |
attempts=0 | |
while [ $attempts -lt 5 ]; do | |
if curl http://localhost:5002; then | |
echo "Success!" | |
exit 0 | |
fi | |
attempts=$((attempts+1)) | |
sleep 1 | |
done | |
echo "Failed after $attempts attempts" | |
exit 1 |