diff --git a/.github/workflows/contributor.yaml b/.github/workflows/contributor.yaml new file mode 100644 index 000000000..8e2abc5b9 --- /dev/null +++ b/.github/workflows/contributor.yaml @@ -0,0 +1,52 @@ +name: Contributor Tests trigger + +on: + issue_comment: + types: [created, edited] + +permissions: + contents: write + pull-requests: write + +jobs: + build: + name: Build + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/bot run tests') && contains(fromJson('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association)}} + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Create comment on the PR + uses: peter-evans/create-or-update-comment@v2 + with: + issue-number: ${{ github.event.issue.number }} + body: | + Contributor Tests Triggered by @${{ github.event.comment.user.login }} + - via [comment](${{ github.event.comment.html_url }}) + - Build is running [here](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) + reactions: 'rocket' + + kubernetes-tests: + name: "Contributor #${{ github.event.issue.number }}" + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/bot run tests') && contains(fromJson('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association)}} + uses: nebari-dev/nebari/.github/workflows/kubernetes_test.yaml@release/2022.11.1 + with: + pr_number: ${{ github.event.issue.number }} + + infracost-tests: + name: "Contributor #${{ github.event.issue.number }}" + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/bot run tests') && contains(fromJson('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association)}} + uses: nebari-dev/nebari/.github/workflows/infracost.yml@release/2022.11.1 + with: + pr_number: ${{ github.event.issue.number }} + + provider-tests: + name: "Contributor #${{ github.event.issue.number }}" + if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, '/bot run tests') && contains(fromJson('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association)}} + uses: nebari-dev/nebari/.github/workflows/test-provider.yaml@release/2022.11.1 + with: + pr_number: ${{ github.event.issue.number }} diff --git a/.github/workflows/infracost.yml b/.github/workflows/infracost.yml index bb2f77786..9ea643c6f 100644 --- a/.github/workflows/infracost.yml +++ b/.github/workflows/infracost.yml @@ -5,6 +5,11 @@ on: paths: - 'nebari/template/stages/02-infrastructure' - '.github/workflows/infracost.yml' + workflow_call: + inputs: + pr_number: + required: true + type: string env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} @@ -38,6 +43,12 @@ jobs: with: ref: '${{ github.event.pull_request.base.ref }}' + - name: Checkout the branch from the PR that triggered the job + if: ${{ github.event_name == 'issue_comment' }} + run: hub pr checkout ${{ inputs.pr_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Detects changes in the infrastructure for each specific cloud service provider - name: Detect changed infrastructure uses: dorny/paths-filter@v2 diff --git a/.github/workflows/kubernetes_test.yaml b/.github/workflows/kubernetes_test.yaml index 2e085be94..952058eab 100644 --- a/.github/workflows/kubernetes_test.yaml +++ b/.github/workflows/kubernetes_test.yaml @@ -24,6 +24,11 @@ on: - "nebari/**" - "setup.cfg" - "pyproject.yoml" + workflow_call: + inputs: + pr_number: + required: true + type: string jobs: test-kubernetes: @@ -33,14 +38,23 @@ jobs: run: shell: bash -l {0} steps: + - name: "Set NEBARI_IMAGE_TAG=main" run: | echo "NEBARI_IMAGE_TAG=main" >> "$GITHUB_ENV" echo "GITHUB_BASE_REF: ${GITHUB_BASE_REF}" echo "GITHUB_HEAD_REF: ${GITHUB_HEAD_REF}" echo "GITHUB_REF: ${GITHUB_REF}" + - name: 'Checkout Infrastructure' uses: actions/checkout@main + + - name: Checkout the branch from the PR that triggered the job + if: ${{ github.event_name == 'issue_comment' }} + run: hub pr checkout ${{ inputs.pr_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Python uses: conda-incubator/setup-miniconda@v2 env: diff --git a/.github/workflows/test-provider.yaml b/.github/workflows/test-provider.yaml index ffcb86f41..e25ef059e 100644 --- a/.github/workflows/test-provider.yaml +++ b/.github/workflows/test-provider.yaml @@ -24,6 +24,11 @@ on: - "nebari/**" - "setup.cfg" - "pyproject.yoml" + workflow_call: + inputs: + pr_number: + required: true + type: string env: DIGITALOCEAN_TOKEN: ${{ secrets.DIGITALOCEAN_TOKEN }} @@ -55,6 +60,13 @@ jobs: steps: - name: 'Checkout Infrastructure' uses: actions/checkout@main + + - name: Checkout the branch from the PR that triggered the job + if: ${{ github.event_name == 'issue_comment' }} + run: hub pr checkout ${{ inputs.pr_number }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Set up Python uses: actions/setup-python@v1 with: