From a7ef821ddd9dbf0fcd19fb3bd9ba8674c58b908f Mon Sep 17 00:00:00 2001 From: Brian Shao Date: Fri, 20 Feb 2026 18:22:11 -0800 Subject: [PATCH 1/2] ci: update ci workflow --- .../{integration-tests.yml => ci.yaml} | 49 +++++++++++++++++-- .github/workflows/test-suite.yml | 15 ------ .github/workflows/unit-tests.yml | 24 --------- 3 files changed, 46 insertions(+), 42 deletions(-) rename .github/workflows/{integration-tests.yml => ci.yaml} (60%) delete mode 100644 .github/workflows/test-suite.yml delete mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/ci.yaml similarity index 60% rename from .github/workflows/integration-tests.yml rename to .github/workflows/ci.yaml index f0b439e..86bdb03 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/ci.yaml @@ -1,12 +1,55 @@ -name: Integration Tests +name: CI on: workflow_call: + pull_request: + branches: [ main ] + +env: + GO_VERSION: '1.25' jobs: + lint: + name: Lint Check + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + + - name: Check formatting + run: gofmt -l . + + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ${{ env.GO_VERSION }} + cache: true + + - name: Download dependencies + run: go mod download + + - name: Run unit tests + run: go test -v -race ./internal/... + integration-tests: + name: Integration Tests runs-on: ubuntu-latest - + services: postgres: image: postgres:17 @@ -29,7 +72,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: '1.25' + go-version: ${{ env.GO_VERSION }} cache: true - name: Install sql-migrate diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml deleted file mode 100644 index 99752f2..0000000 --- a/.github/workflows/test-suite.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: Test Suite - -on: - pull_request: - branches: [ main ] - push: - branches: [ main ] - -jobs: - unit-tests: - uses: ./.github/workflows/unit-tests.yml - - integration-tests: - needs: unit-tests - uses: ./.github/workflows/integration-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml deleted file mode 100644 index 9a695fe..0000000 --- a/.github/workflows/unit-tests.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: Unit Tests - -on: - workflow_call: - -jobs: - unit-tests: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.25' - cache: true - - - name: Download dependencies - run: go mod download - - - name: Run unit tests - run: go test -v -race ./internal/... From 8218370ad2fa7c980c870b02a9df1ef0b4d84928 Mon Sep 17 00:00:00 2001 From: Brian Shao Date: Fri, 20 Feb 2026 18:22:11 -0800 Subject: [PATCH 2/2] ci: create cd workflow --- .github/workflows/deploy.yaml | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..3bb7c90 --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,54 @@ +name: Build and Deploy + +on: + workflow_dispatch: + push: + branches: [ main, "feat/cd" ] + +jobs: + test: + name: Tests + uses: ./.github/workflows/ci.yaml + + build-and-push: + name: Build and Push + needs: test + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + + - name: Login to Amazon ECR Public + id: login-ecr-public + uses: aws-actions/amazon-ecr-login@v2 + with: + registry-type: public + + - name: Build and Push Image + env: + REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} + REGISTRY_ALIAS: d0w1o5s2 + REPOSITORY: ubcea/echo-base + TAG: ${{ github.sha }} + run: | + docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$TAG . + docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$TAG + + deploy: + name: Deploy to EC2 + needs: build-and-push + runs-on: ubuntu-latest + + steps: + - name: Stub + run: | + echo "not implemented" + exit 1