|
| 1 | +name: Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [ main, staging ] |
| 6 | + paths: |
| 7 | + - 'PetAdoptions/cdk/**' |
| 8 | + - 'PetAdoptions/petfood-rs/**' |
| 9 | + push: |
| 10 | + branches: [ main, staging ] |
| 11 | + paths: |
| 12 | + - 'PetAdoptions/cdk/**' |
| 13 | + - 'PetAdoptions/petfood-rs/**' |
| 14 | + |
| 15 | +jobs: |
| 16 | + cdk-synth-test: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Setup Node.js |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: '22' |
| 27 | + |
| 28 | + - name: Cache node modules |
| 29 | + uses: actions/cache@v4 |
| 30 | + with: |
| 31 | + path: PetAdoptions/cdk/pet_stack/node_modules |
| 32 | + key: ${{ runner.os }}-node-${{ hashFiles('PetAdoptions/cdk/pet_stack/package.json') }} |
| 33 | + restore-keys: | |
| 34 | + ${{ runner.os }}-node- |
| 35 | +
|
| 36 | + - name: Install dependencies |
| 37 | + run: npm install |
| 38 | + working-directory: PetAdoptions/cdk/pet_stack |
| 39 | + |
| 40 | + - name: Build TypeScript |
| 41 | + run: npm run build |
| 42 | + working-directory: PetAdoptions/cdk/pet_stack |
| 43 | + |
| 44 | + - name: TypeScript compilation check |
| 45 | + run: npx tsc --noEmit |
| 46 | + working-directory: PetAdoptions/cdk/pet_stack |
| 47 | + |
| 48 | + - name: CDK context validation |
| 49 | + run: | |
| 50 | + echo "Validating CDK context and configuration..." |
| 51 | + npx cdk context --clear |
| 52 | + npx cdk ls |
| 53 | + working-directory: PetAdoptions/cdk/pet_stack |
| 54 | + env: |
| 55 | + AWS_DEFAULT_REGION: us-east-1 |
| 56 | + AWS_REGION: us-east-1 |
| 57 | + AWS_ACCESS_KEY_ID: dummy |
| 58 | + AWS_SECRET_ACCESS_KEY: dummy |
| 59 | + |
| 60 | + - name: Run CDK synth (dry run) |
| 61 | + run: npx cdk synth --no-staging |
| 62 | + working-directory: PetAdoptions/cdk/pet_stack |
| 63 | + env: |
| 64 | + # Set required AWS environment variables for synth |
| 65 | + AWS_DEFAULT_REGION: us-east-1 |
| 66 | + AWS_REGION: us-east-1 |
| 67 | + # CDK doesn't need real AWS credentials for synth, but some constructs might check |
| 68 | + AWS_ACCESS_KEY_ID: dummy |
| 69 | + AWS_SECRET_ACCESS_KEY: dummy |
| 70 | + |
| 71 | + - name: Run CDK diff (if applicable) |
| 72 | + run: npx cdk diff --no-staging || true |
| 73 | + working-directory: PetAdoptions/cdk/pet_stack |
| 74 | + env: |
| 75 | + AWS_DEFAULT_REGION: us-east-1 |
| 76 | + AWS_REGION: us-east-1 |
| 77 | + AWS_ACCESS_KEY_ID: dummy |
| 78 | + AWS_SECRET_ACCESS_KEY: dummy |
| 79 | + |
| 80 | + petfood-rust-test: |
| 81 | + runs-on: ubuntu-latest |
| 82 | + |
| 83 | + steps: |
| 84 | + - name: Checkout code |
| 85 | + uses: actions/checkout@v4 |
| 86 | + |
| 87 | + - name: Setup Rust |
| 88 | + uses: actions-rs/toolchain@v1 |
| 89 | + with: |
| 90 | + toolchain: stable |
| 91 | + profile: minimal |
| 92 | + override: true |
| 93 | + components: rustfmt, clippy |
| 94 | + |
| 95 | + - name: Cache cargo registry |
| 96 | + uses: actions/cache@v4 |
| 97 | + with: |
| 98 | + path: ~/.cargo/registry |
| 99 | + key: ${{ runner.os }}-cargo-registry-${{ hashFiles('PetAdoptions/petfood-rs/Cargo.lock') }} |
| 100 | + restore-keys: | |
| 101 | + ${{ runner.os }}-cargo-registry- |
| 102 | +
|
| 103 | + - name: Cache cargo index |
| 104 | + uses: actions/cache@v4 |
| 105 | + with: |
| 106 | + path: ~/.cargo/git |
| 107 | + key: ${{ runner.os }}-cargo-index-${{ hashFiles('PetAdoptions/petfood-rs/Cargo.lock') }} |
| 108 | + restore-keys: | |
| 109 | + ${{ runner.os }}-cargo-index- |
| 110 | +
|
| 111 | + - name: Cache cargo build |
| 112 | + uses: actions/cache@v4 |
| 113 | + with: |
| 114 | + path: PetAdoptions/petfood-rs/target |
| 115 | + key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('PetAdoptions/petfood-rs/Cargo.lock') }} |
| 116 | + restore-keys: | |
| 117 | + ${{ runner.os }}-cargo-build-target- |
| 118 | +
|
| 119 | + - name: Check Rust formatting |
| 120 | + run: cargo fmt --all -- --check |
| 121 | + working-directory: PetAdoptions/petfood-rs |
| 122 | + |
| 123 | + - name: Run Clippy (linting) |
| 124 | + run: cargo clippy --all-targets --all-features -- -D warnings |
| 125 | + working-directory: PetAdoptions/petfood-rs |
| 126 | + |
| 127 | + - name: Run cargo unit tests |
| 128 | + run: cargo test --lib --bins |
| 129 | + working-directory: PetAdoptions/petfood-rs |
| 130 | + env: |
| 131 | + RUST_BACKTRACE: 1 |
| 132 | + |
| 133 | + # - name: Run cargo tests with all features |
| 134 | + # run: cargo test --all-features --verbose |
| 135 | + # working-directory: PetAdoptions/petfood-rs |
| 136 | + # env: |
| 137 | + # RUST_BACKTRACE: 1 |
| 138 | + |
| 139 | + - name: Check cargo build |
| 140 | + run: cargo build --release |
| 141 | + working-directory: PetAdoptions/petfood-rs |
0 commit comments