From f36cff181b06fbb5bdf037e18716d7383befd74e Mon Sep 17 00:00:00 2001 From: Angelo Dini Date: Fri, 19 Apr 2024 20:59:34 +0200 Subject: [PATCH] feat: add testing framework --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++++ .github/workflows/deploy.yml | 28 ++++++++++++++++++++++++++++ docker-compose.yml | 1 + 3 files changed, 56 insertions(+) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..981c774 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,27 @@ +name: Build template + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build docker image + run: docker-compose build + + - name: Run docker container + run: docker-compose up -d + + - name: Test if service is reachable + run: | + curl -v -s --retry 10 --retry-connrefused http://localhost:8000/ + + - name: Report error to Sentry + if: failure() + run: | + curl -sL https://sentry.io/get-cli/ | bash + export SENTRY_DSN=${{ secrets.SENTRY_DSN }} + MESSAGE="Error in action: ${{ github.workflow }} run. Check for more details in ${{ github.repository }}" + sentry-cli send-event -m "$MESSAGE" --log-level=error diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..049084f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy template + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install divio-cli + + - name: Deploy to Divio + run: | + divio login ${{ secrets.DIVIO_TOKEN }} + divio app deploy test --remote-id ${{ secrets.DIVIO_WEBSITE_ID }} + + - name: Test if website is reachable + run: | + curl -v -s --retry 10 --retry-connrefused ${{ secrets.WEBSITE_URL }} diff --git a/docker-compose.yml b/docker-compose.yml index a300e13..69e338c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,6 +9,7 @@ services: - ".:/app:rw" - "node_modules:/app/node_modules" command: npm run dev -- --host 0.0.0.0 --port 80 + restart: always volumes: node_modules: