diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index c442449..342c014 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -1,7 +1,6 @@ name: deploy-to-server on: - push: pull_request: workflow_call: workflow_dispatch: @@ -21,12 +20,12 @@ jobs: with: key: ${{ secrets.SSH_DATAFRAMETRAINER_KEY }} known_hosts: 'just-a-placeholder-to-not-get-errors' - - name: Adding Known Hosts - run: ssh-keyscan -H ${{ secrets.DATAFRAMETRAINER_SERVER_IP }} >> ~/.ssh/known_hosts - name: Setup tmate session uses: mxschmitt/action-tmate@v3 with: detached: true - name: Sleep forever run: sleep 3600 + - name: Adding Known Hosts + run: ssh-keyscan -H ${{ secrets.DATAFRAMETRAINER_SERVER_IP }} >> ~/.ssh/known_hosts diff --git a/.github/workflows/e2e-tests.yaml b/.github/workflows/e2e-tests.yaml index 7176852..d7de087 100644 --- a/.github/workflows/e2e-tests.yaml +++ b/.github/workflows/e2e-tests.yaml @@ -1,103 +1,103 @@ -name: e2e-tests - -on: - push: - branches: - - 'main' - pull_request: - workflow_call: - workflow_dispatch: - -jobs: - run-e2e-tests-prod: - timeout-minutes: 60 - runs-on: ubuntu-latest - env: - DB_NAME: ${{ secrets.DB_NAME }} - DB_USER: ${{ secrets.DB_USER }} - DB_PORT: ${{ secrets.DB_PORT }} - PASSWORD: ${{ secrets.PASSWORD }} - HOST: ${{ secrets.HOST }} - defaults: - run: - working-directory: ./backend - steps: - - uses: actions/checkout@v3 - - name: Setup docker compose - uses: KengoTODA/actions-setup-docker-compose@v1 - with: - version: '2.14.2' # the full version of `docker-compose` command - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '20' - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.npm - key: npm-${{ hashFiles('package-lock.json') }} - restore-keys: npm- - - name: Install dependencies - working-directory: ./frontend-svelte - run: npm ci - - name: Set .env file - run: | - sed -i "s/__DB_NAME__/$DB_NAME/g" .example.env - sed -i "s/__DB_USER__/$DB_USER/g" .example.env - sed -i "s/__PASSWORD__/$PASSWORD/g" .example.env - sed -i "s/__HOST__/$HOST/g" .example.env - sed -i "s/__DB_PORT__/$DB_PORT/g" .example.env - - # todo: do we need both??? - cp .example.env .env - # this is needed since vite/sveltekit rely on this file when running in production mode - cp .example.env ./frontend-svelte/.env - working-directory: ./ - - - name: Run docker compose - working-directory: . - run: | - ls -la - docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d - - name: Run Cypress tests Chrome - working-directory: ./frontend-svelte - run: npx cypress run --browser chrome --config baseUrl=http://localhost:3000 - # Currently only chrome is supported - # - name: Run Cypress tests Firefox - # working-directory: ./frontend-svelte - # run: npx cypress run --browser firefox - - - name: Run docker compose test - working-directory: . - run: | - ls -la - docker compose -f docker-compose.test.yml up -d - - - name: Check curl response of backend - run: | - # todo: move this into a python script to make this a bit more readable - # wait till the fill-db-with-test-input finished writing to db! todo: this can be done dynamically by checking if the container is still running - sleep 15 - docker container ls - response_code=$(curl -o /dev/null -w "%{http_code}" http://127.0.0.1:5000/get_all_challenges/) - if [ "$response_code" -ne 200 ]; then - echo "Response code is not 200. Failing the pipeline." - exit 1 - fi - - echo "start testing elo endpoints" - response_code=$(curl -X POST http://127.0.0.1:5000/post_next_challenge -H "Content-Type: application/json" -d '{"user_id": "d037ce8d-0381-471f-bfa5-98467685a335"}') - next_challenge=$(echo "$response_code" | grep "next_challenge") - # check if GroupTerms is in the next_challenge string - if [[ "$next_challenge" != *"GroupTerms"* ]]; then - echo "Expected next_challenge to be GroupTerms. Received $next_challenge instead." - echo $response_code - exit 1 - fi - - echo "test set_user_group endpoint" - response_code=$(curl -X POST http://127.0.0.1:5000/set_user_group -H "Content-Type: application/json" -d '{"user_id": "user_elo_id", "session_id": "session_id_user_elo"}') - if [[ "$response_code" != *"success"* ]]; then - echo "Response code is not 200. ." - exit 1 - fi \ No newline at end of file +# name: e2e-tests +# +# on: +# push: +# branches: +# - 'main' +# pull_request: +# workflow_call: +# workflow_dispatch: +# +# jobs: +# run-e2e-tests-prod: +# timeout-minutes: 60 +# runs-on: ubuntu-latest +# env: +# DB_NAME: ${{ secrets.DB_NAME }} +# DB_USER: ${{ secrets.DB_USER }} +# DB_PORT: ${{ secrets.DB_PORT }} +# PASSWORD: ${{ secrets.PASSWORD }} +# HOST: ${{ secrets.HOST }} +# defaults: +# run: +# working-directory: ./backend +# steps: +# - uses: actions/checkout@v3 +# - name: Setup docker compose +# uses: KengoTODA/actions-setup-docker-compose@v1 +# with: +# version: '2.14.2' # the full version of `docker-compose` command +# - name: Setup Node.js +# uses: actions/setup-node@v3 +# with: +# node-version: '20' +# - name: Cache dependencies +# uses: actions/cache@v2 +# with: +# path: ~/.npm +# key: npm-${{ hashFiles('package-lock.json') }} +# restore-keys: npm- +# - name: Install dependencies +# working-directory: ./frontend-svelte +# run: npm ci +# - name: Set .env file +# run: | +# sed -i "s/__DB_NAME__/$DB_NAME/g" .example.env +# sed -i "s/__DB_USER__/$DB_USER/g" .example.env +# sed -i "s/__PASSWORD__/$PASSWORD/g" .example.env +# sed -i "s/__HOST__/$HOST/g" .example.env +# sed -i "s/__DB_PORT__/$DB_PORT/g" .example.env +# +# # todo: do we need both??? +# cp .example.env .env +# # this is needed since vite/sveltekit rely on this file when running in production mode +# cp .example.env ./frontend-svelte/.env +# working-directory: ./ +# - +# name: Run docker compose +# working-directory: . +# run: | +# ls -la +# docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d +# - name: Run Cypress tests Chrome +# working-directory: ./frontend-svelte +# run: npx cypress run --browser chrome --config baseUrl=http://localhost:3000 +# # Currently only chrome is supported +# # - name: Run Cypress tests Firefox +# # working-directory: ./frontend-svelte +# # run: npx cypress run --browser firefox +# - +# name: Run docker compose test +# working-directory: . +# run: | +# ls -la +# docker compose -f docker-compose.test.yml up -d +# - +# name: Check curl response of backend +# run: | +# # todo: move this into a python script to make this a bit more readable +# # wait till the fill-db-with-test-input finished writing to db! todo: this can be done dynamically by checking if the container is still running +# sleep 15 +# docker container ls +# response_code=$(curl -o /dev/null -w "%{http_code}" http://127.0.0.1:5000/get_all_challenges/) +# if [ "$response_code" -ne 200 ]; then +# echo "Response code is not 200. Failing the pipeline." +# exit 1 +# fi +# +# echo "start testing elo endpoints" +# response_code=$(curl -X POST http://127.0.0.1:5000/post_next_challenge -H "Content-Type: application/json" -d '{"user_id": "d037ce8d-0381-471f-bfa5-98467685a335"}') +# next_challenge=$(echo "$response_code" | grep "next_challenge") +# # check if GroupTerms is in the next_challenge string +# if [[ "$next_challenge" != *"GroupTerms"* ]]; then +# echo "Expected next_challenge to be GroupTerms. Received $next_challenge instead." +# echo $response_code +# exit 1 +# fi +# +# echo "test set_user_group endpoint" +# response_code=$(curl -X POST http://127.0.0.1:5000/set_user_group -H "Content-Type: application/json" -d '{"user_id": "user_elo_id", "session_id": "session_id_user_elo"}') +# if [[ "$response_code" != *"success"* ]]; then +# echo "Response code is not 200. ." +# exit 1 +# fi \ No newline at end of file diff --git a/.github/workflows/python-tests.yaml b/.github/workflows/python-tests.yaml index 9016e9d..46a086f 100644 --- a/.github/workflows/python-tests.yaml +++ b/.github/workflows/python-tests.yaml @@ -1,33 +1,34 @@ -name: Run Python Tests - -on: - push: - branches: - - main - paths: - - backend/** - pull_request: - workflow_call: - workflow_dispatch: - -jobs: - run-pytest-on-backend: - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./backend - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.11" - cache: "pip" - cache-dependency-path: "backend/requirements*.txt" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.dev.txt - pip install -r requirements.txt - - name: Test with pytest - run: | - python -m pytest challenges +# name: Run Python Tests +# +# on: +# push: +# branches: +# - main +# paths: +# - backend/** +# # pull_request: +# # workflow_call: +# workflow_dispatch: +# +# jobs: +# run-pytest-on-backend: +# runs-on: ubuntu-latest +# defaults: +# run: +# working-directory: ./backend +# steps: +# - uses: actions/checkout@v3 +# - uses: actions/setup-python@v4 +# with: +# python-version: "3.11" +# cache: "pip" +# cache-dependency-path: "backend/requirements*.txt" +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# pip install -r requirements.dev.txt +# pip install -r requirements.txt +# - name: Test with pytest +# run: | +# python -m pytest challenges +# \ No newline at end of file