name: S3 Bucket Test

on:
  pull_request:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  test-on-os-node-matrix:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest, windows-latest]
        node: [20, 'lts/*']
    env:
      AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
      AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      S3_BUCKET: ${{ secrets.S3_BUCKET }}

    name: Test S3 Bucket - Node ${{ matrix.node }} on ${{ matrix.os }}

    steps:
      - name: Checkout ${{ github.ref }}
        uses: actions/checkout@v6

      - name: Setup node ${{ matrix.node }}
        uses: actions/setup-node@v6
        with:
          node-version: ${{ matrix.node }}

      - name: NPM Install
        run: npm install

      - name: Show Environment Info
        run: |
          printenv
          node --version
          npm --version

      - name: Run S3 Tests (against ${{ env.S3_BUCKET }} bucket)
        run: |
          npm run bucket ${{ env.S3_BUCKET }}
          npm run test:s3
        if: ${{ env.S3_BUCKET != '' }}

