diff --git a/.github/workflows/backend-tests-database-blob.yml b/.github/workflows/backend-tests-database-blob.yml deleted file mode 100644 index e106cd94..00000000 --- a/.github/workflows/backend-tests-database-blob.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Backend Tests - Database Blob - -on: - pull_request: - branches: - - 'master' - - 'master-*' - -jobs: - run_tests_blob_architecture: - runs-on: ubuntu-22.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: "3.11" - architecture: "x64" - env: - AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache - - - name: Install dependencies - working-directory: Backend - run: | - pip install -r requirements.txt - pip install -r requirements-test.txt - - - name: Run tests Database Blob Architecture - working-directory: Backend/ - run: | - python -m pytest tests/ - env: - MONGO_URI: mongodb://root:root@localhost:27017/ - SECRET_KEY_SIGN: ${{ secrets.SECRET_KEY_SIGN }} - SERVERLESS_FUNCTION_URL: ${{ secrets.SERVERLESS_FUNCTION_URL }} - ARCH: "BLOB" - ENV_VALUE: "PROD" - - - name: Fail workflow on test failure - if: ${{ failure() }} - run: exit 1 diff --git a/.github/workflows/backend-tests-streaming-serverless-function.yml b/.github/workflows/backend-tests-streaming-serverless-function.yml deleted file mode 100644 index 7133b773..00000000 --- a/.github/workflows/backend-tests-streaming-serverless-function.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Backend Tests - Streaming Serverless Function - -on: - pull_request: - branches: - - 'master' - - 'master-*' - -jobs: - run_tests_streaming_serverless: - runs-on: ubuntu-22.04 - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Python 3.11 - uses: actions/setup-python@v3 - with: - python-version: "3.11" - architecture: "x64" - env: - AGENT_TOOLSDIRECTORY: /opt/hostedtoolcache - - - name: Install dependencies - working-directory: Backend - run: | - pip install -r requirements.txt - pip install -r requirements-test.txt - - - name: Run tests Streaming Serverless/Lambda function Architecture - working-directory: Backend/ - run: | - python -m pytest tests/ - env: - MONGO_URI: mongodb://root:root@localhost:27017/ - SECRET_KEY_SIGN: ${{ secrets.SECRET_KEY_SIGN }} - SERVERLESS_FUNCTION_URL: ${{ secrets.SERVERLESS_FUNCTION_URL }} - ARCH: "STREAMING_SERVERLESS_FUNCTION" - ENV_VALUE: "PROD" - - - name: Fail workflow on test failure - if: ${{ failure() }} - run: exit 1 diff --git a/.github/workflows/deployment-backend.yml b/.github/workflows/deployment-backend.yml new file mode 100644 index 00000000..c544e2cd --- /dev/null +++ b/.github/workflows/deployment-backend.yml @@ -0,0 +1,66 @@ +name: Docker Deployment Test + +on: + pull_request: + branches: + - 'master' + - 'master-*' + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install Docker prerequisites + run: | + sudo apt-get update + sudo apt-get install -y \ + apt-transport-https \ + ca-certificates \ + curl \ + gnupg \ + lsb-release + + - name: Install Docker dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + software-properties-common + + - name: Add Docker GPG key + run: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + + - name: Set up Docker repository + run: | + echo \ + "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + + - name: Install Docker + run: | + sudo apt-get update + sudo apt-get install -y docker-ce docker-ce-cli containerd.io + sudo systemctl start docker + sudo systemctl enable docker + + - name: Build Docker image + working-directory: Backend/ + run: | + docker build -t spotify_electron_backend_image . + docker run -d --name spotify_electron_backend -e MONGO_URI=mongodb://root:root@localhost:27017/ -e SECRET_KEY_SIGN=f24e2f3ac557d487b6d879fb2d86f2b2 -e SERVERLESS_FUNCTION_URL=url -e ARCH=BLOB -e ENV_VALUE=c -p 8000:8000 spotify_electron_backend_image + + - name: Wait for container to start + run: sleep 20s + + - name: Check container health + run: | + status=$(curl -o /dev/null -s -w '%{http_code}' http://127.0.0.1:8000/health) + if [[ $status -eq 200 ]]; then + echo "Health check successful" + else + echo "Health check failed with status code $status" + exit 1 + fi diff --git a/.github/workflows/eslintrc-check.yml b/.github/workflows/eslintrc-check.yml deleted file mode 100644 index 3774e071..00000000 --- a/.github/workflows/eslintrc-check.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Eslintrc Check - -on: - pull_request: - branches: - - "master" - - "master-*" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: "20" - - - name: Change directory and run commands - working-directory: Electron - run: | - npm install - npm run lint diff --git a/.github/workflows/frontend-style-prettier.yml b/.github/workflows/frontend-style-prettier.yml deleted file mode 100644 index 23ee1002..00000000 --- a/.github/workflows/frontend-style-prettier.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Frontend Style Prettier - -on: - pull_request: - branches: - - "master" - - "master-*" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: "20" - - - name: Change directory and run commands - working-directory: Electron - run: | - npm install - npm run format:check diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml deleted file mode 100644 index 86f22980..00000000 --- a/.github/workflows/frontend-tests.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Frontend Tests - -on: - pull_request: - branches: - - "master" - - "master-*" - -jobs: - build: - runs-on: ubuntu-22.04 - - steps: - - name: Check out code - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: "20" - - - name: Change directory and run commands - working-directory: Electron - run: | - npm install - npm run build - npm test diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml deleted file mode 100644 index 82527368..00000000 --- a/.github/workflows/generate-docs.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Generate Docs - -on: - pull_request: - types: [closed] - -permissions: - contents: write -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Configure Git Credentials - run: | - git config user.name github-actions[bot] - git config user.email 41898282+github-actions[bot]@users.noreply.github.com - - uses: actions/setup-python@v5 - with: - python-version: 3.x - - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV - - uses: actions/cache@v4 - with: - key: mkdocs-material-${{ env.cache_id }} - path: .cache - restore-keys: | - mkdocs-material- - - run: pip install -r requirements-docs.txt - - run: mkdocs gh-deploy --force diff --git a/.github/workflows/ruff-format-check.yml b/.github/workflows/ruff-format-check.yml deleted file mode 100644 index 02756033..00000000 --- a/.github/workflows/ruff-format-check.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: Check Ruff format and styling -on: - pull_request: - branches: - - "master" - - "master-*" -jobs: - ruff: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 - with: - args: "format --check" diff --git a/.github/workflows/ruff-lint-check.yml b/.github/workflows/ruff-lint-check.yml deleted file mode 100644 index 23112be0..00000000 --- a/.github/workflows/ruff-lint-check.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Check Ruff lint -on: - pull_request: - branches: - - "master" - - "master-*" -jobs: - ruff: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 diff --git a/Backend/Dockerfile b/Backend/Dockerfile index bc3d975c..df2dd321 100644 --- a/Backend/Dockerfile +++ b/Backend/Dockerfile @@ -9,6 +9,7 @@ COPY ./app /code/app WORKDIR /code/ CMD ["python", "-m", "app"] +EXPOSE 8000 #CMD ["tail", "-f", "/dev/null"] #docker build -t spotify_electron_backend_image .