diff --git a/.github/actions/publish-from-template/action.yml b/.github/actions/publish-from-template/action.yml new file mode 100644 index 0000000000..1e5117c478 --- /dev/null +++ b/.github/actions/publish-from-template/action.yml @@ -0,0 +1,28 @@ +name: publish-from-template +description: "Publish information from a template" + +inputs: + filename: + description: Path to issue template. Usually in .github/issue-templates + required: true + +runs: + using: composite + + steps: + - name: Render template + # Render template only in CI to make sure rendering on a schedule works as planned + if: github.event_name != 'schedule' + shell: bash + env: ${{ env }} + run: + python .github/actions/publish-from-template/render_template.py ${{ + inputs.filename }} + + - uses: JasonEtco/create-an-issue@v2 + # Only render template and create an issue in case the workflow is a scheduled one + if: github.event_name == 'schedule' + env: ${{ env }} + with: + filename: ${{ inputs.filename }} + update_existing: false diff --git a/.github/actions/publish-from-template/publish-from-template.py b/.github/actions/publish-from-template/publish-from-template.py new file mode 100644 index 0000000000..9c142152d2 --- /dev/null +++ b/.github/actions/publish-from-template/publish-from-template.py @@ -0,0 +1,17 @@ +import os +import pathlib +import sys + +import jinja2 + + +def main(template_path): + loader = jinja2.FileSystemLoader(searchpath=template_path.parent) + env = jinja2.Environment(loader=loader) + template = env.get_template(template_path.name) + print(template.render(env=os.environ)) + + +if __name__ == "__main__": + template_path = pathlib.Path(sys.argv[1]) + main(template_path) diff --git a/.github/failed-workflow-issue-templates/test-provider.md b/.github/failed-workflow-issue-templates/test-provider.md new file mode 100644 index 0000000000..254988cb4b --- /dev/null +++ b/.github/failed-workflow-issue-templates/test-provider.md @@ -0,0 +1,5 @@ +--- +title: Provider CI jobs fail for {{ env.PROVIDER }} / {{ env.CICD }} +--- + +See /~https://github.com/{{ env.REPO }}/actions/runs/{{ env.ID }} for details. diff --git a/.github/workflows/contributor.yaml b/.github/workflows/contributor.yaml deleted file mode 100644 index 603e61980f..0000000000 --- a/.github/workflows/contributor.yaml +++ /dev/null @@ -1,83 +0,0 @@ -name: Contributor Tests trigger - -on: - issue_comment: - types: [created, edited] - -permissions: - contents: write - pull-requests: write - -jobs: - trigger-contributor-tests: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Comment is not on a PR - if: ${{ !github.event.issue.pull_request }} - run: exit 1 - - - name: Comment does not contains the trigger phrase - if: ${{ !contains(github.event.comment.body, '/bot run tests') }} - run: | - echo ${{ github.event.comment.body }} - exit 1 - - - name: Author of comment has insufficient permissions - if: ${{ !contains(fromJson('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) }} - run: | - echo ${{ github.event.comment.author_association }} - echo - echo If you think you should have the right permissions to trigger this, - echo they are likely not visible publicly! - echo - echo To fix this - echo - echo 1. navigate to /~https://github.com/nebari-dev, - echo 2. click on \'People\' in the top bar, - echo 3. scroll down to your entry, and - echo 4. change \'🔒 Private\' to \'Public\'. - exit 1 - - build: - needs: trigger-contributor-tests - 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: - needs: trigger-contributor-tests - name: "Contributor #${{ github.event.issue.number }}" - uses: nebari-dev/nebari/.github/workflows/kubernetes_test.yaml@develop - with: - pr_number: ${{ github.event.issue.number }} - secrets: inherit - -# FIXME: this needs write permissions, but they might not be available for PRs coming from a fork -# provider-tests: -# needs: trigger-contributor-tests -# name: "Contributor #${{ github.event.issue.number }}" -# uses: nebari-dev/nebari/.github/workflows/test-provider.yaml@develop -# with: -# pr_number: ${{ github.event.issue.number }} -# secrets: inherit diff --git a/.github/workflows/kubernetes_test.yaml b/.github/workflows/kubernetes_test.yaml index c62a766f4d..eaaa2fe8cc 100644 --- a/.github/workflows/kubernetes_test.yaml +++ b/.github/workflows/kubernetes_test.yaml @@ -33,7 +33,6 @@ on: jobs: test-kubernetes: - if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' name: "Kubernetes Tests" runs-on: "cirun-runner--${{ github.run_id }}" defaults: diff --git a/.github/workflows/markdown.links.config.json b/.github/workflows/markdown.links.config.json deleted file mode 100644 index f9118ad72c..0000000000 --- a/.github/workflows/markdown.links.config.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "ignorePatterns": [ - { - "pattern": "developers.cloudflare.com" - }, - { - "pattern": "support.cloudflare.com" - }, - { - "pattern": "linuxize.com" - }, - { - "pattern": "github-actions.nebari.dev" - }, - { - "pattern": "127.0.0.1:8000" - }, - { - "pattern": "mynebarisite.com" - }, - { - "pattern": "https://cloud.google.com" - } - ], - "timeout": "20s", - "retryOn429": true, - "retryCount": 5, - "fallbackRetryDelay": "30s", - "aliveStatusCodes": [200, 206] -} diff --git a/.github/workflows/test-provider.yaml b/.github/workflows/test-provider.yaml index 10d22d1a2e..d75c071032 100644 --- a/.github/workflows/test-provider.yaml +++ b/.github/workflows/test-provider.yaml @@ -1,9 +1,14 @@ +# This is only workflow that requires cloud credentials and therefore will not run on PRs coming from forks. name: "Test Nebari Provider" on: + schedule: + - cron: "0 3 * * *" pull_request: paths: - ".github/workflows/test-provider.yaml" + - ".github/failed-workflow-issue-templates/test-provider.md" + - ".github/actions/publish-from-template" - "tests/**" - "tests_deployment/**" - "tests_e2e/**" @@ -31,6 +36,7 @@ on: jobs: test-render-providers: + # avoid running on PRs coming from a fork if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' name: "Test Nebari Provider" runs-on: ubuntu-latest @@ -134,3 +140,13 @@ jobs: with: name: "nebari-${{ matrix.provider }}-${{ matrix.cicd }}-artifact" path: "nebari-${{ matrix.provider }}-${{ matrix.cicd }}-deployment" + + - if: failure() || github.event_name == 'pull_request' + name: Publish information from template + uses: ./.github/actions/publish-from-template + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PROVIDER: ${{ matrix.provider }} + CICD: ${{ matrix.cicd }} + with: + filename: .github/failed-workflow-issue-templates/provider-tests.md diff --git a/README.md b/README.md index c5e88de90b..437f5a3702 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ | :---------- | :-----| | Project | [![License](https://img.shields.io/badge/License-BSD%203--Clause-gray.svg?colorA=2D2A56&colorB=5936D9&style=flat.svg)](https://opensource.org/licenses/BSD-3-Clause) [![Nebari documentation](https://img.shields.io/badge/%F0%9F%93%96%20Read-the%20docs-gray.svg?colorA=2D2A56&colorB=5936D9&style=flat.svg)](https://www.nebari.dev/docs/welcome) [![PyPI](https://img.shields.io/pypi/v/nebari)](https://badge.fury.io/py/nebari) [![conda version](https://img.shields.io/conda/vn/conda-forge/nebari)]((https://anaconda.org/conda-forge/nebari)) | | Community | [![GH discussions](https://img.shields.io/badge/%F0%9F%92%AC%20-Participate%20in%20discussions-gray.svg?colorA=2D2A56&colorB=5936D9&style=flat.svg)](/~https://github.com/nebari-dev/nebari/discussions) [![Open an issue](https://img.shields.io/badge/%F0%9F%93%9D%20Open-an%20issue-gray.svg?colorA=2D2A56&colorB=5936D9&style=flat.svg)](/~https://github.com/nebari-dev/nebari/issues/new/choose) [![Community guidelines](https://img.shields.io/badge/🤝%20Community-guidelines-gray.svg?colorA=2D2A56&colorB=5936D9&style=flat.svg)](https://www.nebari.dev/docs/community/) | -| CI | [![Kubernetes Tests](/~https://github.com/nebari-dev/nebari/actions/workflows/kubernetes_test.yaml/badge.svg)](/~https://github.com/nebari-dev/nebari/actions/workflows/kubernetes_test.yaml) [![Tests](/~https://github.com/nebari-dev/nebari/actions/workflows/test.yaml/badge.svg)](/~https://github.com/nebari-dev/nebari/actions/workflows/test.yaml) | +| CI | [![Kubernetes Tests](/~https://github.com/nebari-dev/nebari/actions/workflows/kubernetes_test.yaml/badge.svg)](/~https://github.com/nebari-dev/nebari/actions/workflows/kubernetes_test.yaml) [![Tests](/~https://github.com/nebari-dev/nebari/actions/workflows/test.yaml/badge.svg)](/~https://github.com/nebari-dev/nebari/actions/workflows/test.yaml) [![Test Nebari Provider](/~https://github.com/nebari-dev/nebari/actions/workflows/test-provider.yaml/badge.svg)](/~https://github.com/nebari-dev/nebari/actions/workflows/test-provider.yaml) | ## Table of contents diff --git a/pyproject.toml b/pyproject.toml index 97b39254d6..a1c745ae2c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,7 @@ dev = [ "pytest-timeout", "grayskull", "build", + "jinja2", ] [project.urls]