Skip to content

Commit

Permalink
Add github actions to test e2e (#184)
Browse files Browse the repository at this point in the history
* Trying

* Trying

* Trying
  • Loading branch information
turulomio authored Aug 11, 2024
1 parent b046135 commit abda870
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 1 deletion.
82 changes: 82 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main", "181-add-github-actions" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: github_actions
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

strategy:
max-parallel: 4
matrix:
python-version: ["3.11"]
node-version: [18.x]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install PL/Python in the PostgreSQL container (Old migrations)
run: |
# Version can change see in docker page wich is postgres:latest
docker exec ${{ job.services.postgres.id }} bash -c "PGPASSWORD=postgres createdb -h localhost -U postgres calories_tracker"
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432; do
echo "Waiting for PostgreSQL to become ready..."
sleep 2
done
- name: Install python3.11 and other packages
run: |
sudo apt-get install python3.11 python3.11-venv exiftool
- name: Install python dependencies ${{ matrix.python-version }} and launch django_calories_tracker
run: |
cd ..
git clone https://github.com/turulomio/django_calories_tracker
cd django_calories_tracker
sudo python3.11 -m venv .python3.11
sudo .python3.11/bin/pip install .
sudo .python3.11/bin/python manage.py testserver calories_tracker/fixtures/all.json calories_tracker/fixtures/test_server.json --addrport 8011 &
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: CaloriesTracker install and test build
run: |
npm install
npm run build --if-present
- name: CaloriesTracker e2e test
run: |
npm run dev &
sleep 10
npm run cypress_console
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ node_modules
.env.*.local

# Log files
npm-debug.log*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
Expand Down

0 comments on commit abda870

Please sign in to comment.