diff --git a/.cirun.yml b/.cirun.yml index 207bb5a888..eec94207bf 100644 --- a/.cirun.yml +++ b/.cirun.yml @@ -6,8 +6,8 @@ runners: cloud: aws # Instance Type has 4 vcpu, 16 GiB memory, Up to 5 Gbps Network Performance instance_type: t3a.xlarge - # Custom AMI with docker is pre-installed - machine_image: ami-0ff297f01f579288c + # Custom AMI with docker/cypress/hub pre-installed + machine_image: ami-0cdc9ef51d44597ce # Region: Oregon region: us-west-2 # Use Spot Instances for cost savings diff --git a/.github/workflows/contributor.yaml b/.github/workflows/contributor.yaml new file mode 100644 index 0000000000..c788cd264e --- /dev/null +++ b/.github/workflows/contributor.yaml @@ -0,0 +1,55 @@ +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 }} + secrets: inherit + + 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 }} + secrets: inherit + + 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 }} + secrets: inherit diff --git a/.github/workflows/infracost.yml b/.github/workflows/infracost.yml index bb2f77786a..f46ad71da5 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 }} @@ -16,6 +21,7 @@ env: jobs: infracost: + if: github.event.pull_request.head.repo.name == github.repository || github.event_name != 'pull_request' name: Run Infracost on Nebari Infrastructure runs-on: ubuntu-latest @@ -38,6 +44,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 2e085be946..d6285f4901 100644 --- a/.github/workflows/kubernetes_test.yaml +++ b/.github/workflows/kubernetes_test.yaml @@ -10,7 +10,7 @@ on: - "scripts/**" - "nebari/**" - "setup.cfg" - - "pyproject.yoml" + - "pyproject.toml" push: branches: - main @@ -24,23 +24,40 @@ on: - "nebari/**" - "setup.cfg" - "pyproject.yoml" + workflow_call: + inputs: + pr_number: + required: true + type: string jobs: test-kubernetes: + if: github.event.pull_request.head.repo.name == github.repository || github.event_name != 'pull_request' name: "Kubernetes Tests" runs-on: "cirun-runner--${{ github.run_id }}" defaults: 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 version + 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 ffcb86f410..21c18ab574 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 }} @@ -37,6 +42,7 @@ env: jobs: test-render-providers: + if: github.event.pull_request.head.repo.name == github.repository || github.event_name != 'pull_request' name: 'Test Nebari Provider' runs-on: ubuntu-latest strategy: @@ -55,6 +61,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: