Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation of syn-teams.libsonnet #1

Merged
merged 16 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/01_bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: 🐜 Bug report
about: Create a report to help us improve 🔧
labels: bug
---

<!-- Place a general description or your issue here. -->

## Steps to Reproduce the Problem
<!-- Tell us how to reproduce your issue -->

1.
1.
1.

## Actual Behavior
<!-- What did happen as a result of the above? -->

## Expected Behavior
<!-- What is your expectation of the result? -->
18 changes: 18 additions & 0 deletions .github/ISSUE_TEMPLATE/02_feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
name: 🚀 Feature request
about: Suggest an idea for this project 💡
labels: enhancement
---

## Context
<!--
Please let us know what you are trying to do and how you would want to do it differently?
Is it something you currently cannot do?
Is this related to an issue/problem?
-->

## Alternatives
<!--
Can you achieve the same result doing it in an alternative way?
Is the alternative considerable?
-->
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
blank_issues_enabled: false
simu marked this conversation as resolved.
Show resolved Hide resolved
contact_links:
- name: ❓ Help and Support RocketChat Channel
url: https://community.appuio.ch
about: Please ask and answer questions here. 🏥
26 changes: 26 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@



## Checklist

- [ ] The PR has a meaningful title. It will be used to auto-generate the
changelog.
The PR has a meaningful description that sums up the change. It will be
linked in the changelog.
- [ ] PR contains a single logical change (to build a better changelog).
- [ ] Update the documentation.
- [ ] Categorize the PR by adding one of the labels:
`bug`, `enhancement`, `documentation`, `change`, `breaking`, `dependency`
as they show up in the changelog.
- [ ] Link this PR to related issues or PRs.

<!--
Thank you for your pull request. Please provide a description above and
review the checklist.

Contributors guide: ./CONTRIBUTING.md

Remove items that do not apply. For completed items, change [ ] to [x].
These things are not required to open a PR and can be done afterwards
while the PR is open.
-->
30 changes: 30 additions & 0 deletions .github/changelog-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"pr_template": "- ${{TITLE}} (#${{NUMBER}})",
"categories": [
{
"title": "## 🚀 Features",
"labels": ["enhancement", "feature"]
},
{
"title": "## 🛠️ Minor Changes",
"labels": ["change"]
},
{
"title": "## 🔎 Breaking Changes",
"labels": ["breaking"]
},
{
"title": "## 🐛 Fixes",
"labels": ["bug", "fix"]
},
{
"title": "## 📄 Documentation",
"labels": ["documentation"]
},
{
"title": "## 🔗 Dependency Updates",
"labels": ["dependency"]
}
],
"template": "${{CATEGORIZED_COUNT}} changes since ${{FROM_TAG}}\n\n${{CHANGELOG}}"
}
18 changes: 18 additions & 0 deletions .github/workflows/auto-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Autorelease
simu marked this conversation as resolved.
Show resolved Hide resolved
on:
simu marked this conversation as resolved.
Show resolved Hide resolved
pull_request:
types:
- synchronize
- labeled
- unlabeled
- closed

jobs:
create-release-tag:
runs-on: ubuntu-latest
steps:
- name: Create new tag
uses: projectsyn/pr-label-tag-action@v1
with:
trigger: |
Release
33 changes: 33 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release
simu marked this conversation as resolved.
Show resolved Hide resolved
on:
simu marked this conversation as resolved.
Show resolved Hide resolved
push:
tags:
- v*
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"
- name: Build changelog from PRs with labels
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
configuration: ".github/changelog-configuration.json"
# PreReleases still get a changelog, but the next full release gets a diff since the last full release,
simu marked this conversation as resolved.
Show resolved Hide resolved
# combining possible changelogs of all previous PreReleases in between.
simu marked this conversation as resolved.
Show resolved Hide resolved
# PreReleases show a partial changelog since last PreRelease.
ignorePreReleases: "${{ !contains(github.ref, '-rc') }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: ncipollo/release-action@v1
with:
body: ${{steps.build_changelog.outputs.changelog}}
prerelease: "${{ contains(github.ref, '-rc') }}"
# Ensure target branch for release is "master"
commit: master
token: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Lint & Test

"on":
pull_request: {}

jobs:
jsonnetfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
make jsonnetfmt_check

test_libraries_discover_cases:
name: Discover golden test cases
runs-on: ubuntu-latest
outputs:
instances: ${{ steps.instances.outputs.instances }}
steps:
- uses: actions/checkout@v4
- name: Find test cases
id: instances
run: |
echo "instances=$(make -s list_test_instances)" >> "$GITHUB_OUTPUT"

test_libraries:
needs: test_libraries_discover_cases
strategy:
matrix:
instance: ${{ fromJSON(needs.test_libraries_discover_cases.outputs.instances) }}
simu marked this conversation as resolved.
Show resolved Hide resolved
runs-on: ubuntu-latest
name: 'Golden test: ${{ matrix.instance }}'
steps:
- uses: actions/checkout@v4
- run: |
make golden-diff -e instance=${{ matrix.instance }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tests/lib
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c

include Makefile.vars.mk

.PHONY: jsonnetfmt_check jsonnetfmt
jsonnetfmt_check: JSONNET_ENTRYPOINT=jsonnetfmt
jsonnetfmt_check:
$(JSONNET_DOCKER) --test --pad-arrays -- *.libsonnet

jsonnetfmt: JSONNET_ENTRYPOINT=jsonnetfmt
jsonnetfmt:
$(JSONNET_DOCKER) --in-place --pad-arrays -- *.libsonnet

tests/lib/commodore-real.libjsonnet:
@mkdir -p "tests/lib"
curl -fsSLo "tests/lib/commodore-real.libjsonnet" https://raw.githubusercontent.com/projectsyn/commodore/refs/heads/master/commodore/lib/commodore.libjsonnet

.PHONY: gen-golden
gen-golden: tests/lib/commodore-real.libjsonnet
$(JSONNET_DOCKER) tests/run-instance.sh $(instance) > tests/golden/$(instance).yml

.PHONY: golden-diff
golden-diff: tests/lib/commodore-real.libjsonnet
@mkdir -p /tmp/golden
$(JSONNET_DOCKER) tests/run-instance.sh $(instance) > /tmp/golden/$(instance).yml
@git diff --exit-code --minimal --no-index -- tests/golden/$(instance).yml /tmp/golden/$(instance).yml

.PHONY: golden-diff-all
golden-diff-all: recursive_target=golden-diff
golden-diff-all: $(test_instances)

.PHONY: gen-golden-all
gen-golden-all: recursive_target=gen-golden
gen-golden-all: $(test_instances)

.PHONY: $(test_instances)
$(test_instances):
$(MAKE) $(recursive_target) -e instance=$(basename $(@F))

.PHONY: list_test_instances
list_test_instances: JSONNET_ENTRYPOINT=jsonnet
list_test_instances:
$(JSONNET_DOCKER) -J . -J tests --ext-str instances="$(basename $(notdir $(test_instances)))" -e 'std.split(std.extVar("instances"), " ")' | jq -c
15 changes: 15 additions & 0 deletions Makefile.vars.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ifneq "$(shell which docker 2>/dev/null)" ""
DOCKER_CMD ?= $(shell which docker)
DOCKER_USERNS ?= ""
else
DOCKER_CMD ?= podman
DOCKER_USERNS ?= keep-id
endif
DOCKER_ARGS ?= run --rm -u "$$(id -u):$$(id -g)" --userns=$(DOCKER_USERNS) -w /work -e HOME="/work"

JSONNET_IMAGE ?= docker.io/bitnami/jsonnet:latest
JSONNET_ENTRYPOINT ?= bash
JSONNET_DOCKER ?= $(DOCKER_CMD) $(DOCKER_ARGS) -v "$${PWD}:/work" --entrypoint=$(JSONNET_ENTRYPOINT) $(JSONNET_IMAGE)

test_instances=$(shell find tests/ -maxdepth 1 -name '*.jsonnet')
instance=syn-teams
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This repository contains shared Jsonnet libraries that can be included by Commod
This repository is part of Project Syn.
For documentation on Project Syn and this component, see [syn.tools](https://syn.tools).

See individual top-level `*.libsonnet` files for details on each library that's provided in this repository.

## Contributing and license

This library is licensed under [BSD-3-Clause](LICENSE).
Expand Down
Loading
Loading