diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 9dbcd73..be87e7c 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -3,7 +3,7 @@ name: Build and Deploy Code on: [push, pull_request] jobs: - build: + build-ci: environment: name: testing env: @@ -40,15 +40,43 @@ jobs: with: python-version: '3.10' - - name: Update pip - run: python -m pip install --upgrade pip - - name: Install dependencies - run: pip install -r requirements.txt + #- name: Update pip + # run: python -m pip install --upgrade pip + #- name: Install dependencies + # run: pip install -r requirements.txt - - name: Run tests with PyTest + #- name: Run tests with PyTest + # run: | + # pip install pytest + # pytest -v + + #- name: Install Poetry version 1.7.1 + # uses: abatilo/actions-poetry@v2 + # with: + # poetry-version: '1.7.1' + #- name: View poetry --help + # run: poetry --help + #- name: Run poetry install + # run: poetry install + + - name: Install Poetry version 1.7.1 + uses: abatilo/actions-poetry@v2 + with: + poetry-version: '1.7.1' + - name: Setup a local virtual environment (if no poetry.toml file) run: | - pip install pytest - pytest -v + poetry config virtualenvs.create true --local + poetry config virtualenvs.in-project true --local + - uses: actions/cache@v3 + name: Define a cache for the virtual environment based on the dependencies lock file + with: + path: ./.venv + key: venv-${{ hashFiles('poetry.lock') }} + - name: Install the project dependencies + run: poetry install + - name: Run the automated tests with PyTest + run: poetry run pytest -v + #- name: Login to Docker Hub # uses: docker/login-action@v3 @@ -69,11 +97,11 @@ jobs: #- name: Image digest # run: echo ${{ steps.docker_build.outputs.digest }} - deploy: + deploy-cd: environment: name: production runs-on: ubuntu-20.04 - needs: build + needs: build-ci steps: - name: Checkout Pulling Git Repo uses: actions/checkout@v4 @@ -87,6 +115,7 @@ jobs: script: | cd api/src git pull + poetry install echo ${{ secrets.PROD_PASSWORD }} | sudo -S systemctl restart api # login to our vps ubuntu server with ssh # cd api/src