|
1 | 1 | name: Build and deploy contracts |
2 | 2 |
|
3 | 3 | on: |
| 4 | + push: |
| 5 | + branches: [ main, develop ] |
4 | 6 | pull_request: |
5 | | - branches: |
6 | | - - main |
7 | | - - develop |
8 | 7 |
|
9 | 8 | jobs: |
10 | | - changed_files: |
| 9 | + detect-changes: |
| 10 | + name: Detect Changes |
11 | 11 | runs-on: ubuntu-latest |
12 | | - name: Test changed-files |
| 12 | + outputs: |
| 13 | + sdk: ${{ steps.changed-files.outputs.sdk_changed }} |
| 14 | + smart_contract: ${{ steps.changed-files.outputs.smart_contract_changed }} |
| 15 | + subgraph: ${{ steps.changed-files.outputs.subgraph_changed }} |
| 16 | + dapp: ${{ steps.changed-files.outputs.dapp_changed }} |
13 | 17 | steps: |
14 | | - - uses: actions/checkout@v4 |
| 18 | + - name: Checkout code |
| 19 | + uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + # Adjust fetch-depth as needed |
| 22 | + fetch-depth: 0 |
15 | 23 |
|
16 | | - - name: Get changed files |
| 24 | + - name: Detect package changes |
17 | 25 | id: changed-files |
18 | 26 | uses: tj-actions/changed-files@v45 |
19 | 27 | with: |
20 | | - matrix: 'true' |
| 28 | + files_yaml: | |
| 29 | + sdk: |
| 30 | + - 'packages/sdk/**' |
| 31 | + smart_contract: |
| 32 | + - 'packages/smart-contract/**' |
| 33 | + subgraph: |
| 34 | + - 'packages/subgraph/**' |
| 35 | + dapp: |
| 36 | + - 'packages/protected-data-delivery-dapp/**' |
| 37 | + # Enable matrix output for use in subsequent jobs |
| 38 | + matrix: true |
| 39 | + |
| 40 | + build-and-test: |
| 41 | + name: Build & Test Modified Packages |
| 42 | + needs: detect-changes |
| 43 | + runs-on: ubuntu-latest |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + package: [ sdk, smart_contract, subgraph, dapp ] |
| 47 | + # Run this job only if changes were detected in the respective package |
| 48 | + if: ${{ fromJson(needs.detect-changes.outputs[matrix.package]).any_changed == 'true' }} |
| 49 | + steps: |
| 50 | + - name: Checkout code |
| 51 | + uses: actions/checkout@v4 |
| 52 | + |
| 53 | + - name: Setup Node.js |
| 54 | + uses: actions/setup-node@v4 |
| 55 | + with: |
| 56 | + node-version: '18' |
21 | 57 |
|
22 | | - - name: Run step if any file(s) in the docs folder change |
23 | | - if: steps.changed-files-specific.outputs.any_changed == 'true' |
24 | | - env: |
25 | | - ALL_CHANGED_FILES: ${{ steps.changed-files-specific.outputs.all_changed_files }} |
| 58 | + - name: Install dependencies and run tests for ${{ matrix.package }} |
| 59 | + working-directory: packages/${{ matrix.package }} |
26 | 60 | run: | |
27 | | - echo "One or more files in the docs folder has changed." |
28 | | - echo "List all the files that have changed: $ALL_CHANGED_FILES" |
| 61 | + npm ci |
| 62 | + npm run test |
0 commit comments