Skip to content

Commit

Permalink
Simplify CI (#1819)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
  • Loading branch information
iameskild and pmeier authored Jun 19, 2023
1 parent b6222b6 commit a6d032f
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 115 deletions.
28 changes: 28 additions & 0 deletions .github/actions/publish-from-template/action.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions .github/actions/publish-from-template/publish-from-template.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 5 additions & 0 deletions .github/failed-workflow-issue-templates/test-provider.md
Original file line number Diff line number Diff line change
@@ -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.
83 changes: 0 additions & 83 deletions .github/workflows/contributor.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .github/workflows/kubernetes_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
30 changes: 0 additions & 30 deletions .github/workflows/markdown.links.config.json

This file was deleted.

16 changes: 16 additions & 0 deletions .github/workflows/test-provider.yaml
Original file line number Diff line number Diff line change
@@ -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/**"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ dev = [
"pytest-timeout",
"grayskull",
"build",
"jinja2",
]

[project.urls]
Expand Down

0 comments on commit a6d032f

Please sign in to comment.