Skip to content

Commit d24e8f1

Browse files
committed
feat: run real sync against github test org in tests
1 parent 234da90 commit d24e8f1

File tree

7 files changed

+153
-0
lines changed

7 files changed

+153
-0
lines changed

.github/workflows/real-test.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Test with real GitHub org
6+
7+
on:
8+
pull_request:
9+
workflow_dispatch:
10+
11+
jobs:
12+
selftest:
13+
runs-on: ubuntu-24.04
14+
env:
15+
GITHUB_APP_ID: ${{ secrets.TEST_GITHUB_APP_ID }}
16+
GITHUB_APP_PRIVATE_KEY: ${{ secrets.TEST_GITHUB_APP_PRIVATE_KEY }}
17+
steps:
18+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
19+
- uses: ./.github/actions/poetrybuild
20+
- name: Replace data in config files
21+
run: |
22+
sed -i "s/TEST_GITHUB_ORG/${{ secrets.TEST_GITHUB_ORG }}/g" tests/data/config/org_files/*.yaml
23+
sed -i "s/TEST_USER/${{ secrets.TEST_USER }}/g" tests/data/config/org_files/*.yaml
24+
sed -i "s/TEST_USER/${{ secrets.TEST_USER }}/g" tests/data/config/teams_files/*.yaml
25+
- name: Prepare for first run
26+
run: |
27+
mkdir -p tests/data/config/teams
28+
cp tests/data/config/teams_files/teams_changes.yaml tests/data/config/teams/teams.yaml
29+
cp tests/data/config/org_files/org_changes.yaml tests/data/config/org.yaml
30+
- name: Run 1 (changes) - dry run
31+
run: poetry run gh-org-mgr sync -c tests/data/config/ --dry -vv
32+
- name: Run 1 (changes) - prod run
33+
run: poetry run gh-org-mgr sync -c tests/data/config/ -vv
34+
- name: Prepare for second run, reverting to original state
35+
run: |
36+
cp tests/data/config/teams_files/teams_orig.yaml tests/data/config/teams/teams.yaml
37+
cp tests/data/config/org_files/org_orig.yaml tests/data/config/org.yaml
38+
- name: Run 2 (revert) - dry run
39+
run: poetry run gh-org-mgr sync -c tests/data/config/ --dry -vv
40+
- name: Run 2 (revert) - prod run
41+
run: poetry run gh-org-mgr sync -c tests/data/config/ -vv

tests/data/config/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
org.yaml
5+
teams/teams.yaml

tests/data/config/app.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2024 DB Systel GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
# ------------------------------------------------------------------------------
5+
# General configuration for this program
6+
# ------------------------------------------------------------------------------
7+
8+
# github_token: ghp_test
9+
# github_app_id: 12345
10+
# github_app_private_key: |
11+
# ------BEGIN RSA PRIVATE KEY-----
12+
# ...
13+
# ------END RSA PRIVATE KEY-----
14+
15+
# Delete teams that are not configured
16+
delete_unconfigured_teams: true
17+
18+
# Remove members that are not configured
19+
remove_members_without_team: true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
# ------------------------------------------------------------------------------
5+
# General configuration for the GitHub organisation
6+
# ------------------------------------------------------------------------------
7+
8+
# Name of the GitHub organisation
9+
org_name: TEST_GITHUB_ORG
10+
org_owners:
11+
- TEST_USER
12+
13+
# Default settings. Will be overridden if set in a team.
14+
# If neither defaults nor team settings are present:
15+
# - when creating a new team, will take GitHub's defaults.
16+
# - when syncing settting of a team, will not touch the current status.
17+
defaults:
18+
team:
19+
# Description of a team
20+
# description: ""
21+
# Level of privacy of a team. Can be "secret" or "closed"
22+
privacy: "secret"
23+
# Notification setting of a team. Can be "notifications_enabled" or "notifications_disabled"
24+
notification_setting: "notifications_enabled"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
# ------------------------------------------------------------------------------
5+
# General configuration for the GitHub organisation
6+
# ------------------------------------------------------------------------------
7+
8+
# Name of the GitHub organisation
9+
org_name: TEST_GITHUB_ORG
10+
org_owners:
11+
- TEST_USER
12+
13+
# Default settings. Will be overridden if set in a team.
14+
# If neither defaults nor team settings are present:
15+
# - when creating a new team, will take GitHub's defaults.
16+
# - when syncing settting of a team, will not touch the current status.
17+
defaults:
18+
team:
19+
# Description of a team
20+
# description: ""
21+
# Level of privacy of a team. Can be "secret" or "closed"
22+
privacy: "closed"
23+
# Notification setting of a team. Can be "notifications_enabled" or "notifications_disabled"
24+
notification_setting: "notifications_enabled"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
Test1:
5+
description: First test team with a new description
6+
privacy: closed
7+
member:
8+
- TEST_USER
9+
10+
Test2:
11+
parent: Test1
12+
privacy: closed
13+
description: Second test team
14+
maintainer:
15+
- TEST_USER
16+
17+
Test3:
18+
notification_setting: notifications_disabled
19+
privacy: closed
20+
21+
Test3-child:
22+
parent: Test3
23+
description: Child of Test3
24+
privacy: closed
25+
member:
26+
- TEST_USER
27+
28+
Test4:
29+
member:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-FileCopyrightText: 2025 DB Systel GmbH
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
Test1:
5+
description: First test team
6+
member:
7+
8+
Test2:
9+
privacy: secret
10+
description: Second test team
11+
member:

0 commit comments

Comments
 (0)