Skip to content

Commit

Permalink
Add project automation & cleanup validator code
Browse files Browse the repository at this point in the history
  • Loading branch information
jsangmeister committed Feb 5, 2024
1 parent 0ac662a commit 9716ac4
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/announce-file-changes-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: '{{ env.OS_ISSUE_TITLE }}'
assignees: luisa-beerboom
labels: documentation
---

# Changes to `{{ env.OS_FILE_NAME }}` have just been added to OpenSlides

Please acknowledge the recent changes to `{{ env.OS_FILE_NAME }}` and update your projects accordingly.

### Corresponding Commit:

[{{ env.GITHUB_SHA }}]({{ env.GITHUB_SERVER_URL }}/{{ env.GITHUB_REPOSITORY }}/commit/{{ env.GITHUB_SHA }})
62 changes: 62 additions & 0 deletions .github/workflows/create-issue-for-file-updates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
name: Create issues if global files change
on:
push:
branches:
- main
paths:
- 'global/meta/models.yml'
- 'global/meta/permission.yml'

jobs:
announce-update:
name: 'Announce updates'
runs-on: ubuntu-latest
if: github.repository_owner == 'OpenSlides'
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v42

- name: Create Issue if models.yml was changed
if: contains(steps.changed-files.outputs.modified_files, 'global/meta/models.yml')
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS_ISSUE_TITLE: The `models.yml` got updated
OS_FILE_NAME: models.yml
with:
filename: .github/workflows/announce-file-changes-template.md

- name: Create Issue if permission.yml was changed
if: contains(steps.changed-files.outputs.modified_files, 'global/meta/permission.yml')
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OS_ISSUE_TITLE: The `permission.yml` got updated
OS_FILE_NAME: permission.yml
with:
filename: .github/workflows/announce-file-changes-template.md

- name: Generate access token
uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.AUTOMATION_APP_ID }}
private_key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }}

- name: Send dispatch if models.yml or permission.yml was changed
if: |
contains(steps.changed-files.outputs.modified_files, 'global/meta/models.yml') ||
contains(steps.changed-files.outputs.modified_files, 'global/meta/permission.yml')
uses: peter-evans/repository-dispatch@v3
with:
event-type: models-update
repository: ${{ github.repository_owner }}/openslides-autoupdate-service
token: ${{ steps.generate-token.outputs.token }}
client-payload: '{"body": "Triggered by commit [${{ github.sha }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})"}'
32 changes: 32 additions & 0 deletions .github/workflows/project-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Project automation
on:
workflow_call:
inputs:
resource_node_id:
required: true
type: string
status_value:
required: true
type: string
secrets:
AUTOMATION_APP_ID:
required: true
AUTOMATION_APP_INSTALLATION_ID:
required: true
AUTOMATION_APP_PRIVATE_KEY:
required: true

jobs:
workflow_call:
name: Set status
runs-on: ubuntu-latest
steps:
- uses: leonsteinhaeuser/project-beta-automations@v2.2.1
with:
gh_app_ID: ${{ secrets.AUTOMATION_APP_ID }}
gh_app_installation_ID: ${{ secrets.AUTOMATION_APP_INSTALLATION_ID }}
gh_app_secret_key: ${{ secrets.AUTOMATION_APP_PRIVATE_KEY }}
organization: OpenSlides
project_id: 2
resource_node_id: ${{ inputs.resource_node_id }}
status_value: ${{ inputs.status_value }}
14 changes: 14 additions & 0 deletions .github/workflows/project-issue-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Project automation
on:
issues:
types:
- closed

jobs:
issue_closed:
name: Issue closed
uses: ./.github/workflows/project-automation.yml
secrets: inherit
with:
resource_node_id: ${{ github.event.issue.node_id }}
status_value: "Done"
15 changes: 15 additions & 0 deletions .github/workflows/project-issue-opened.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Project automation
on:
issues:
types:
- opened
- reopened

jobs:
issue_opened:
name: Issue opened
uses: ./.github/workflows/project-automation.yml
secrets: inherit
with:
resource_node_id: ${{ github.event.issue.node_id }}
status_value: "Backlog"
14 changes: 14 additions & 0 deletions .github/workflows/project-pull-request-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Project automation
on:
pull_request_target:
types:
- closed

jobs:
pull_request_closed:
name: Pull request closed
uses: ./.github/workflows/project-automation.yml
secrets: inherit
with:
resource_node_id: ${{ github.event.pull_request.node_id }}
status_value: "Done"
15 changes: 15 additions & 0 deletions .github/workflows/project-pull-request-opened.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Project automation
on:
pull_request_target:
types:
- opened
- reopened

jobs:
pull_request_opened:
name: Pull request opened
uses: ./.github/workflows/project-automation.yml
secrets: inherit
with:
resource_node_id: ${{ github.event.pull_request.node_id }}
status_value: "Work in progress"
14 changes: 14 additions & 0 deletions .github/workflows/project-pull-request-review-requested.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Project automation
on:
pull_request_target:
types:
- review_requested

jobs:
pull_request_review_requested:
name: Pull request review requested
uses: ./.github/workflows/project-automation.yml
secrets: inherit
with:
resource_node_id: ${{ github.event.pull_request.node_id }}
status_value: "Review in progress"
4 changes: 1 addition & 3 deletions models_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@

COLLECTION_REGEX = re.compile(f"^{_collection_regex}$")
FIELD_REGEX = re.compile(f"^{_field_regex}$")
COLLECTIONFIELD_REGEX = re.compile(
f"^{_collection_regex}{KEYSEPARATOR}{_field_regex}$"
)
COLLECTIONFIELD_REGEX = re.compile(f"^{_collection_regex}{KEYSEPARATOR}{_field_regex}$")

DECIMAL_REGEX = re.compile(r"^-?(\d|[1-9]\d+)\.\d{6}$")
COLOR_REGEX = re.compile(r"^#[0-9a-f]{6}$")
Expand Down

0 comments on commit 9716ac4

Please sign in to comment.