diff --git a/.github/actions/run_tests.yaml b/.github/actions/run_tests.yaml deleted file mode 100644 index 6e0aea7..0000000 --- a/.github/actions/run_tests.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Run unit tests -on: - push: - branches: - - "*" - pull_request: - branches: - - "*" -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Set up Python 3.11 - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - name: Checkout code - uses: actions/checkout@v4 - - name: Install dependencies - run: pip install -r requirements.txt - - name: Run tests - run: python -m unittest discover diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 50c9355..e756b43 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,32 +1,20 @@ --- -name: Docker build +name: Docker build and tests on: push: branches: - - main env: DOCKER_IMAGE_NAME: parseltongist/bank_app DOCKERFILE_DIRECTORY: ./ jobs: - build: + build-and-run-tests: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Build Docker Image run: | - docker build -t $DOCKER_IMAGE_NAME:latest . - working-directory: ${{ env.DOCKERFILE_DIRECTORY }} - - name: Log in to Docker Hub - if: success() - run: | - echo ${{ secrets.DOCKER_PASSWORD }} | - docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - name: Push Docker image to the Docker Hub - if: success() - run: | - docker push $DOCKER_IMAGE_NAME:latest + docker build -t test-tag . working-directory: ${{ env.DOCKERFILE_DIRECTORY }} + - name: TEST VIA DOCKER + run: docker run test-tag diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index e67511d..c0d65e6 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -1,26 +1,26 @@ -name: pre-commit -on: - pull_request: - push: -env: - DOCKER_IMAGE_NAME: parseltongist/bank_app - DOCKERFILE_DIRECTORY: ./ -jobs: - pre-commit: - name: pre-commit - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - uses: pre-commit/action@v3.0.1 - docker-build: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Build Docker Image - run: | - docker build -t $DOCKER_IMAGE_NAME:latest . - working-directory: ${{ env.DOCKERFILE_DIRECTORY }} +#name: pre-commit +#on: +# pull_request: +# push: +#env: +# DOCKER_IMAGE_NAME: parseltongist/bank_app +# DOCKERFILE_DIRECTORY: ./ +#jobs: +# pre-commit: +# name: pre-commit +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - uses: actions/setup-python@v5 +# with: +# python-version: 3.11 +# - uses: pre-commit/action@v3.0.1 +# docker-build: +# runs-on: ubuntu-latest +# steps: +# - name: Checkout code +# uses: actions/checkout@v4 +# - name: Build Docker Image +# run: | +# docker build -t $DOCKER_IMAGE_NAME:latest . +# working-directory: ${{ env.DOCKERFILE_DIRECTORY }} diff --git a/.github/workflows/run_tests.yaml b/.github/workflows/run_tests.yaml new file mode 100644 index 0000000..24fbbb4 --- /dev/null +++ b/.github/workflows/run_tests.yaml @@ -0,0 +1,23 @@ +#--- +#name: Run unit tests +#on: +# push: +# branches: +# - "*" +# pull_request: +# branches: +# - "*" +#jobs: +# build: +# runs-on: ubuntu-latest +# steps: +# - name: Set up Python 3.11 +# uses: actions/setup-python@v5 +# with: +# python-version: 3.11 +# - name: Checkout code +# uses: actions/checkout@v4 +# - name: Install dependencies +# run: pip install -r requirements.txt +# - name: Run tests +# run: python -m unittest discover diff --git a/Dockerfile b/Dockerfile index 64320fa..48a4233 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,12 +7,12 @@ WORKDIR /app RUN set -ex \ && apk add --update --no-cache git python3 py3-pip \ - && git clone $GIT_REPO_URL $PROJECT_FOLDER -b main --depth=1\ - && python3 -m venv venv \ - && source venv/bin/activate \ - && pip install -r $PROJECT_FOLDER/requirements.txt\ + && git clone $GIT_REPO_URL $PROJECT_FOLDER -b refactor-workflow --depth=1 \ + && python3 -m venv venv \ + && chmod +x ./venv/bin/activate \ + && ./venv/bin/pip install -r $PROJECT_FOLDER/requirements.txt \ && ln -sf /usr/bin/python3.11 /usr/bin/python \ && apk del git \ && rm -rf /var/cache/apk/* /root/.cache $PROJECT_FOLDER/.git -CMD ["python3", "bank_app"] +CMD ["./venv/bin/python", "-m", "unittest", "discover", "bank_app"] diff --git a/requirements.txt b/requirements.txt index e7db63b..943f3cc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ SQLAlchemy==2.0.20 tabulate==0.9.0 +sqlalchemy