diff --git a/.github/workflows/after-success.yml b/.github/workflows/after-success.yml deleted file mode 100644 index c05bb6d1..00000000 --- a/.github/workflows/after-success.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: After Success - -on: - workflow_run: - workflows: ["PR Tests"] - types: - - completed - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Confirm Success - run: echo "Previous workflow was successful!" diff --git a/.github/workflows/aws-preview.yml b/.github/workflows/aws-preview.yml index 5654fa83..40992023 100644 --- a/.github/workflows/aws-preview.yml +++ b/.github/workflows/aws-preview.yml @@ -1,10 +1,18 @@ name: Deploy Backend to Preview ECS +# on: +# workflow_run: +# workflows: ["PR Tests"] +# types: +# - completed on: - workflow_run: - workflows: ["PR Tests"] - types: - - completed + pull_request: + branches: [ "main" ] + paths: + - .github/workflows/aws-preview.yml + - server/** + - petercat_utils/** + - subscriber/** env: AWS_REGION: ap-northeast-1 diff --git a/.github/workflows/pr-tests.yml b/.github/workflows/pr-tests.yml index 88342daf..d145c8b9 100644 --- a/.github/workflows/pr-tests.yml +++ b/.github/workflows/pr-tests.yml @@ -2,15 +2,65 @@ name: PR Tests on: pull_request: - branches: - - main + branches: [ "main" ] + paths: + - .github/workflows/aws-preview.yml + - server/** + - petercat_utils/** + - subscriber/** + +permissions: + id-token: write # This is required for requesting the JWT + contents: read # This is required for actions/checkout + pull-requests: write + actions: write + +env: + AWS_REGION: ap-northeast-1 + REPORT_FILE: md_report.md jobs: - test: + build: runs-on: ubuntu-latest + environment: Preview + strategy: + fail-fast: true + defaults: + run: + working-directory: ./server steps: - - name: Check out code - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: arn:aws:iam::654654285942:role/Github-OIDC + audience: sts.amazonaws.com + aws-region: ${{ env.AWS_REGION }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.12.0' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + pip install ruff + pip install pytest pytest-cov pytest-md-report + + - name: Lint with Ruff + run: | + ruff check --output-format=github . - - name: Run a simple test - run: echo "Running tests..." + - name: Test with pytest + run: | + pytest -v --md-report --md-report-output ${{ env.REPORT_FILE }} + cat ${{ env.REPORT_FILE }} + + - name: Comment PR + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: ./server/${{ env.REPORT_FILE }} \ No newline at end of file