diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 6b60e64eeb..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,62 +0,0 @@ -# Python CircleCI 2.1 configuration file -version: 2.1 - -jobs: - build: - machine: - # Check https://circleci.com/developer/machine/image/ubuntu-2004 for details: - image: default - docker_layer_caching: true - steps: - - checkout - - run: - name: build docker base image - command: | - export DOCKER_BUILDKIT=1 - cp .env-sample .env - docker-compose build --progress plain serve - docker-compose pull db redis - - run: - name: Validate if there are no pending django migrations. - command: | - docker-compose run --rm serve ./manage.py makemigrations --check --dry-run || { - echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations'; - exit 1; - } - - run: - name: Validate SentryMonitor config - command: | - docker-compose run --rm serve ./manage.py cron_job_monitor --validate-only || { - echo 'There are some changes to be reflected in the SentryMonitor. Make sure to update SentryMonitor'; - exit 1; - } - - run: - name: Run tests - command: | - time docker-compose run --rm serve ./manage.py test --keepdb -v 2 --pattern="test_fake.py" && - docker-compose run --rm serve pytest --reuse-db --durations=10 - - run: - name: Push image to Docker Hub - command: | - if [ "${CIRCLE_BRANCH}" == "master" ] || [ "${CIRCLE_BRANCH}" == "develop" ]|| [ "${CIRCLE_BRANCH}" == "remotetest" ]; then - { - if [ "${CIRCLE_BRANCH}" == "develop" ]; then - LATEST_GIT_TAG=develop && - echo $LATEST_GIT_TAG - elif [ "${CIRCLE_BRANCH}" == "remotetest" ]; then - LATEST_GIT_TAG=remotetest && - echo $LATEST_GIT_TAG - else - LATEST_GIT_TAG=$(git describe --tags --abbrev=0 --match 1.*) && - echo $LATEST_GIT_TAG - git checkout tags/$LATEST_GIT_TAG -b latest_git_tag - fi - - docker-compose build - docker login -u $DOCKER_USER -p $DOCKER_PASS - docker tag ifrcgo/go-api:latest ifrcgo/go-api:$LATEST_GIT_TAG - docker push ifrcgo/go-api:$LATEST_GIT_TAG - } || { - echo 'No tag matching the condition found' - } - fi diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index b024411da3..0000000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Python check - -on: - push: - branches: - - develop - pull_request: - - -jobs: - pre_commit_checks: - name: ๐Ÿšด Pre-Commit checks ๐Ÿšด - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@main - - name: Install poetry - run: pipx install poetry - - uses: actions/setup-python@main - with: - cache: 'poetry' - - run: poetry install - - uses: pre-commit/action@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..1c748a15f4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,71 @@ +name: CI + +on: + workflow_call: + pull_request: + # NOTE: For develop & master, they are run through helm github action ./build-publish-docker-helm.yml + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + +jobs: + pre_commit_checks: + name: ๐Ÿšด Pre-Commit checks ๐Ÿšด + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + - name: Install poetry + run: pipx install poetry + - uses: actions/setup-python@main + with: + cache: 'poetry' + - run: poetry install + - uses: pre-commit/action@main + + test: + name: ๐Ÿšด Checks & Test ๐Ÿšด + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@main + + - name: ๐Ÿณ Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: ๐Ÿณ Build image + uses: docker/build-push-action@v6 + with: + context: . + file: Dockerfile + push: false + load: true + tags: ifrcgo/go-api:latest + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Docker config setup & Pull docker images + run: | + cp .env-sample .env && + docker compose run --rm serve ls + + - name: ๐Ÿ•ฎ Validate if there are no pending django migrations. + run: | + docker compose run --rm serve ./manage.py makemigrations --check --dry-run || { + echo 'There are some changes to be reflected in the migration. Make sure to run makemigrations'; + exit 1; + } + + - name: ๐Ÿ•ฎ Validate SentryMonitor config + run: | + docker compose run --rm serve ./manage.py cron_job_monitor --validate-only || { + echo 'There are some changes to be reflected in the SentryMonitor. Make sure to update SentryMonitor'; + exit 1; + } + + - name: ๐Ÿคž Run Test ๐Ÿงช + run: | + time docker compose run --rm serve ./manage.py test --keepdb -v 2 --pattern="test_fake.py" && + docker compose run --rm serve pytest --reuse-db --durations=10