|
| 1 | +name: "CI/CD Pipeline" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - develop |
| 7 | + - 'ls-release/**' |
| 8 | + paths: |
| 9 | + - deploy/** |
| 10 | + - label_studio/** |
| 11 | + - setup.py |
| 12 | + - .github/workflows/cicd_pipeline.yml |
| 13 | + - .github/workflows/pr-labeler.yml |
| 14 | + - .github/workflows/submodules-validator.yml |
| 15 | + - .github/workflows/gitleaks.yml |
| 16 | + - .github/workflows/bandit.yml |
| 17 | + - .github/workflows/docker-build.yml |
| 18 | + - .github/workflows/tests.yml |
| 19 | + pull_request_target: |
| 20 | + types: |
| 21 | + - opened |
| 22 | + - synchronize |
| 23 | + - reopened |
| 24 | + - ready_for_review |
| 25 | + branches: |
| 26 | + - develop |
| 27 | + - 'ls-release/**' |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.pull_request.head.ref || github.ref }} |
| 31 | + cancel-in-progress: true |
| 32 | + |
| 33 | +jobs: |
| 34 | + changed_files: |
| 35 | + name: "Changed files" |
| 36 | + runs-on: ubuntu-latest |
| 37 | + outputs: |
| 38 | + src: ${{ steps.changes.outputs.src }} |
| 39 | + frontend: ${{ steps.changes.outputs.frontend }} |
| 40 | + docker: ${{ steps.changes.outputs.docker }} |
| 41 | + commit-message: ${{ steps.commit-details.outputs.message }} |
| 42 | + timeout-minutes: 5 |
| 43 | + steps: |
| 44 | + |
| 45 | + |
| 46 | + - name: Checkout |
| 47 | + if: github.event_name == 'push' |
| 48 | + uses: actions/checkout@v3 |
| 49 | + with: |
| 50 | + ref: ${{ github.ref }} |
| 51 | + |
| 52 | + - uses: dorny/paths-filter@v2 |
| 53 | + id: changes |
| 54 | + with: |
| 55 | + filters: | |
| 56 | + src: |
| 57 | + - 'label_studio/!(frontend)/**' |
| 58 | + - 'deploy/requirements**' |
| 59 | + - 'setup.py' |
| 60 | + frontend: |
| 61 | + - 'label_studio/frontend/**' |
| 62 | + docker: |
| 63 | + - 'label_studio/**' |
| 64 | + - 'deploy/**' |
| 65 | + - 'Dockerfile**' |
| 66 | + - 'setup.py' |
| 67 | + - '.github/workflows/cicd_pipeline.yml' |
| 68 | + - '.github/workflows/docker-build.yml' |
| 69 | +
|
| 70 | + - uses: actions/github-script@v6 |
| 71 | + id: commit-details |
| 72 | + with: |
| 73 | + github-token: ${{ secrets.GIT_PAT }} |
| 74 | + script: | |
| 75 | + const { repo, owner } = context.repo; |
| 76 | + const { data: commit } = await github.rest.repos.getCommit({ |
| 77 | + owner, |
| 78 | + repo, |
| 79 | + ref: '${{ github.event.pull_request.head.sha || github.event.after }}' |
| 80 | + }); |
| 81 | + core.setOutput("message", commit.commit.message); |
| 82 | +
|
| 83 | + pr_labeler: |
| 84 | + name: "Validate" |
| 85 | + if: github.event_name == 'pull_request_target' |
| 86 | + uses: heartexlabs/label-studio/.github/workflows/pr-labeler.yml@develop |
| 87 | + secrets: inherit |
| 88 | + |
| 89 | + validate_submodules: |
| 90 | + name: "Validate" |
| 91 | + uses: heartexlabs/label-studio/.github/workflows/submodules-validator.yml@develop |
| 92 | + with: |
| 93 | + repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }} |
| 94 | + head_sha: ${{ github.event.pull_request.head.sha || github.event.after }} |
| 95 | + base_sha: ${{ github.event.pull_request.base.sha || github.event.before }} |
| 96 | + target_branch: ${{ github.event.pull_request.base.ref || github.event.ref }} |
| 97 | + secrets: inherit |
| 98 | + |
| 99 | + gitleaks: |
| 100 | + name: "Linter" |
| 101 | + if: github.event_name == 'pull_request_target' |
| 102 | + uses: heartexlabs/label-studio/.github/workflows/gitleaks.yml@develop |
| 103 | + with: |
| 104 | + repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }} |
| 105 | + head_sha: ${{ github.event.pull_request.head.sha || github.event.after }} |
| 106 | + base_sha: ${{ github.event.pull_request.base.sha || github.event.before }} |
| 107 | + secrets: inherit |
| 108 | + |
| 109 | + bandit: |
| 110 | + name: "Linter" |
| 111 | + needs: |
| 112 | + - changed_files |
| 113 | + if: needs.changed_files.outputs.src == 'true' |
| 114 | + uses: heartexlabs/label-studio/.github/workflows/bandit.yml@develop |
| 115 | + with: |
| 116 | + repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }} |
| 117 | + head_sha: ${{ github.event.pull_request.head.sha || github.event.after }} |
| 118 | + secrets: inherit |
| 119 | + |
| 120 | + frontend-build: |
| 121 | + name: "Build" |
| 122 | + needs: |
| 123 | + - changed_files |
| 124 | + if: | |
| 125 | + github.event_name == 'pull_request_target' && |
| 126 | + needs.changed_files.outputs.frontend == 'true' && |
| 127 | + needs.changed_files.outputs.commit-message != 'Build frontend' |
| 128 | + uses: heartexlabs/label-studio/.github/workflows/frontend-build.yml@develop |
| 129 | + with: |
| 130 | + ref: ${{ github.event.pull_request.head.ref || github.ref }} |
| 131 | + secrets: inherit |
| 132 | + |
| 133 | + build: |
| 134 | + name: "Build" |
| 135 | + needs: |
| 136 | + - changed_files |
| 137 | + if: github.event_name == 'push' && github.ref == 'refs/heads/develop' && needs.changed_files.outputs.docker == 'true' |
| 138 | + uses: heartexlabs/label-studio/.github/workflows/docker-build.yml@develop |
| 139 | + with: |
| 140 | + ref: ${{ github.event.pull_request.head.ref || github.ref }} |
| 141 | + secrets: inherit |
| 142 | + |
| 143 | + pytest: |
| 144 | + name: "Tests" |
| 145 | + needs: |
| 146 | + - changed_files |
| 147 | + if: needs.changed_files.outputs.src == 'true' |
| 148 | + uses: heartexlabs/label-studio/.github/workflows/tests.yml@develop |
| 149 | + with: |
| 150 | + repo: ${{ github.event.pull_request.head.repo.full_name || github.event.repo.name || github.repository }} |
| 151 | + ref: ${{ github.event.pull_request.head.ref || github.ref }} |
| 152 | + secrets: inherit |
0 commit comments