Skip to content

fix: workflow docker compose #7

fix: workflow docker compose

fix: workflow docker compose #7

Workflow file for this run

name: Service Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Lint with flake8
run: |
# stop if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Create .env file
run: |
cat << EOF > .env
TELEGRAM_TOKEN=${{ secrets.TELEGRAM_TOKEN }}
TEST_TELEGRAM_TOKEN=${{ secrets.TEST_TELEGRAM_TOKEN }}
FEEDBACK_CHANNEL_ID=${{ secrets.FEEDBACK_CHANNEL_ID }}
MONGO_URL=${{ secrets.MONGO_URL }}
REPO_URL=${{ github.server_url }}/${{ github.repository }}
EOF
- name: Build and Test Service
run: |
docker compose build
docker compose up -d
START_TIME=$(date +%s)
END_TIME=$((START_TIME + 60))
while [ $(date +%s) -lt $END_TIME ]; do
if ! docker ps | grep -q terrier-alert; then
echo "Service crashed!"
docker compose logs
exit 1
fi
sleep 5
done
echo "Service ran stable for 1 minute"
docker compose down