diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml new file mode 100644 index 0000000000..207f742488 --- /dev/null +++ b/.github/workflows/pull-request.yaml @@ -0,0 +1,109 @@ +############################################################################## +############################################################################## +# +# NOTE! +# +# Please read the README.md file in this directory that defines what should +# be placed in this file. +# +############################################################################## +############################################################################## +jobs: + check_base_branch: + # only run the job if the pull request actor is not dependabot + if: ${{ github.actor != 'dependabot[bot]' }} + name: Check base branch of the pull request to be dev-postgres + runs-on: ubuntu-latest + steps: + - if: github.event.pull_request.base.ref != 'dev-postgres' + name: Check base branch + run: | + echo "Pull requests are only allowed against the 'dev-postgres' branch. Please refer to the pull request guidelines." + exit 1 + check_code_quality: + name: Checking code quality + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + - name: Build talawa api non production environment docker image + run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./ + - name: Check type errors + run: docker container run talawa_api pnpm check_code_quality + check_gql_tada: + name: Check gql tada files and configuration + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + - name: Build talawa api non production environment docker image + run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./ + - name: Check gql tada + run: docker container run talawa_api pnpm check_gql_tada + check_drizzle_migrations: + name: Check drizzle migration files + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + - name: Build talawa api non production environment docker image + run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./ + - name: Check drizzle migrations + run: docker container run --env-file ./envFiles/.env.ci talawa_api pnpm check_drizzle_migrations + check_type_errors: + name: Check type errors + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + - name: Build talawa api non production environment docker image + run: docker buildx build --file ./docker/api.Containerfile --tag talawa_api --target non_production ./ + - name: Check type errors + run: docker container run talawa_api pnpm check_type_errors + check_unauthorized_file_changes: + if: ${{ github.actor != 'dependabot[bot]' }} + name: Check if there are unauthorized file changes + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + - id: changed_files + name: Get changed files + uses: tj-actions/changed-files@v45 + with: + files: | + .coderabbit.yaml + .github/** + biome.jsonc + drizzle_migrations/** + CODEOWNERS + LICENSE + tsconfig.json + vitest.config.ts + - env: + CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }} + if: steps.changed_files.outputs.any_changed == 'true' || steps.changed_files.outputs.any_deleted == 'true' + name: Show changed files + run: | + echo "Unauthorized changes were made in the following files:" + for FILE in ${CHANGED_FILES}; do + echo "$FILE" + done + exit 1 + run_tests: + name: Run tests for talawa api + runs-on: ubuntu-latest + steps: + - name: Checkout this repository + uses: actions/checkout@v4 + - name: Create .env file for talawa api testing environment + run: cp ./envFiles/.env.ci ./.env + - name: Build talawa api compose testing environment + run: docker compose build + - name: Run tests + run: docker compose up --exit-code-from api +name: Pull request workflow +on: + pull_request: + branches: + - "**" \ No newline at end of file