# GENERATED BY ./node_compat_test.ts -- DO NOT DIRECTLY EDIT

name: node_compat_test
on:
  schedule:
    - cron: 0 10 * * *
  workflow_dispatch: {}
jobs:
  test:
    runs-on: '${{ matrix.runner }}'
    strategy:
      matrix:
        include:
          - os: linux
            runner: ubuntu-latest
            shard_index: '0'
            shard_total: '3'
            shard_label: (1/3)
          - os: linux
            runner: ubuntu-latest
            shard_index: '1'
            shard_total: '3'
            shard_label: (2/3)
          - os: linux
            runner: ubuntu-latest
            shard_index: '2'
            shard_total: '3'
            shard_label: (3/3)
          - os: windows
            runner: windows-latest
            shard_index: '0'
            shard_total: '3'
            shard_label: (1/3)
          - os: windows
            runner: windows-latest
            shard_index: '1'
            shard_total: '3'
            shard_label: (2/3)
          - os: windows
            runner: windows-latest
            shard_index: '2'
            shard_total: '3'
            shard_label: (3/3)
          - os: darwin
            runner: macos-latest
            shard_index: '0'
            shard_total: '3'
            shard_label: (1/3)
          - os: darwin
            runner: macos-latest
            shard_index: '1'
            shard_total: '3'
            shard_label: (2/3)
          - os: darwin
            runner: macos-latest
            shard_index: '2'
            shard_total: '3'
            shard_label: (3/3)
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
        with:
          submodules: false
      - name: Clone node_compat suite submodule
        run: git submodule update --init --recursive --depth=1 -- ./tests/node_compat/runner/suite
      - name: Setup Rust
        uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621
      - name: Setup Deno
        uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282
        with:
          deno-version: canary
      - name: Install Python
        uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
        with:
          python-version: 3.11
      - name: Authenticate with Google Cloud
        uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093
        if: github.ref == 'refs/heads/main'
        with:
          project_id: denoland
          credentials_json: '${{ secrets.GCP_SA_KEY }}'
          export_environment_variables: true
          create_credentials_file: true
      - name: Setup gcloud
        uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db
        if: github.ref == 'refs/heads/main'
        with:
          project_id: denoland
      - name: Run tests
        env:
          CARGO_ENCODED_RUSTFLAGS: ''
          CI_SHARD_INDEX: '${{ matrix.shard_index }}'
          CI_SHARD_TOTAL: '${{ matrix.shard_total }}'
        run: deno task --cwd tests/node_compat/runner test --report
      - name: Gzip the report
        run: gzip tests/node_compat/report.json
      - name: Upload the report to dl.deno.land
        if: github.ref == 'refs/heads/main'
        env:
          AWS_ACCESS_KEY_ID: '${{ vars.S3_ACCESS_KEY_ID }}'
          AWS_SECRET_ACCESS_KEY: '${{ secrets.S3_SECRET_ACCESS_KEY }}'
          AWS_ENDPOINT_URL_S3: '${{ vars.S3_ENDPOINT }}'
          AWS_DEFAULT_REGION: '${{vars.S3_REGION }}'
        run: 'aws s3 cp tests/node_compat/report.json.gz s3://dl-deno-land/node-compat-test/$(date +%F)/report-${{matrix.os}}-${{matrix.shard_index}}.json.gz'
  summary:
    needs:
      - test
    if: always() && github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
        with:
          submodules: false
      - name: Clone std submodule
        run: git submodule update --init --recursive --depth=1 -- ./tests/util/std
      - name: Setup Deno
        uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282
      - name: Install Python
        uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405
        with:
          python-version: 3.11
      - name: Authenticate with Google Cloud
        uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093
        with:
          project_id: denoland
          credentials_json: '${{ secrets.GCP_SA_KEY }}'
          export_environment_variables: true
          create_credentials_file: true
      - name: Setup gcloud
        uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db
        with:
          project_id: denoland
      - name: Add the day summary to the month summary
        run: deno -A --config tests/config/deno.json tests/node_compat/add_day_summary_to_month_summary.ts
      - name: Gzip the month summary
        run: gzip tests/node_compat/summary.json -k
      - name: Upload the month summary
        env:
          AWS_ACCESS_KEY_ID: '${{ vars.S3_ACCESS_KEY_ID }}'
          AWS_SECRET_ACCESS_KEY: '${{ secrets.S3_SECRET_ACCESS_KEY }}'
          AWS_ENDPOINT_URL_S3: '${{ vars.S3_ENDPOINT }}'
          AWS_DEFAULT_REGION: '${{vars.S3_REGION }}'
        run: 'aws s3 cp tests/node_compat/summary.json.gz s3://dl-deno-land/node-compat-test/summary-$(date +%Y-%m).json.gz'
      - name: Post message to slack channel
        env:
          SLACK_TOKEN: '${{ secrets.NODE_COMPAT_SLACK_TOKEN }}'
          SLACK_CHANNEL: '${{ secrets.NODE_COMPAT_SLACK_CHANNEL }}'
        run: deno -A --config tests/config/deno.json tests/node_compat/slack.ts

# gagen:pin actions/checkout@v6 = de0fac2e4500dabe0009e67214ff5f5447ce83dd
# gagen:pin actions/setup-python@v6 = a309ff8b426b58ec0e2a45f0f869d46889d02405
# gagen:pin denoland/setup-deno@v2 = 667a34cdef165d8d2b2e98dde39547c9daac7282
# gagen:pin dsherret/rust-toolchain-file@v1 = 3551321aa44dd44a0393eb3b6bdfbc5d25ecf621
# gagen:pin google-github-actions/auth@v3 = 7c6bc770dae815cd3e89ee6cdf493a5fab2cc093
# gagen:pin google-github-actions/setup-gcloud@v3 = aa5489c8933f4cc7a4f7d45035b3b1440c9c10db
