name: test-adapter on: [pull_request] jobs: test: runs-on: ubuntu-latest steps: - id: file_changes uses: trilom/file-changes-action@ce38c8ce2459ca3c303415eec8cb0409857b4272 with: output: 'json' fileOutput: 'json' - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - uses: pnpm/action-setup@v4 name: Install pnpm with: version: 10 run_install: false - name: Install Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: 'pnpm' - name: Install dependencies run: pnpm install - name: Record PR number run: | mkdir -p pr-comments echo "${{ github.event.number }}" > pr-comments/pr-number.txt - name: Run changes files through test script run: | # Store the current commit hash in a variable current_commit=$(git rev-parse HEAD) # Checkout to master to check if new adapters files are of v2 git fetch origin master:master # Checkout back to the original commit git checkout $current_commit RUN_FILES=$( MODIFIED=${{ steps.file_changes.outputs.files_modified}} \ ADDED=${{ steps.file_changes.outputs.files_added}} \ node ${{ github.workspace }}/.github/workflows/getFileList.js ) if [ "$RUN_FILES" = "[]" ]; then echo "No adapter files were modified" exit 0 fi list=$(echo $RUN_FILES | tr -d '"[]' | tr "," "\n") for i in ${list} do { IFS='@' read -r -a array <<< "$i" npm run test ${array[0]} ${array[1]} 2>&1 | tee output.txt node ${{ github.workspace }}/.github/workflows/commentResult.js ${{ github.workspace }}/output.txt ${{ github.workspace }}/pr-comments ${i} if grep -q "\-\-\-\- ERROR \-\-\-\-" output.txt; then exit 1; fi } || { echo -n $i echo ' doesnt run' } done - name: Upload PR comments artifact if: always() uses: actions/upload-artifact@v4 with: name: pr-comments path: pr-comments/ if-no-files-found: ignore retention-days: 1