Skip to content

Commit 03c07b1

Browse files
committed
Add a job to warn about modulesync changes
01cfc20 added headers, but this isn't really a good experience for users. It's actually much better to fail in CI if a diff is detected. That gives them also a way to verify their changes to .sync.yml are correct. This takes the approach of checking out the modulesync config with the version from .msync.yml and running a one off change in offline mode. Then it uses git diff to see if there are differences. That should fail the build and also show the actual differences, which makes debugging easier.
1 parent 8faa0b8 commit 03c07b1

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# Managed by modulesync - DO NOT EDIT
3+
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
4+
5+
name: Modulesync
6+
7+
on: pull_request
8+
9+
jobs:
10+
compare_with_repo:
11+
name: 'Compare with config'
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Puppet module repository
15+
uses: actions/checkout@v2
16+
with:
17+
path: modules/${{ github.repository }}
18+
19+
- name: Setup ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: '3.0'
23+
24+
- name: Set modulesync version
25+
run: ruby -ryaml -e 'puts "MSYNC_VER=#{YAML.safe_load(File.read(".msync.yml"))["modulesync_config_version"]}"' >> $GITHUB_ENV
26+
working-directory: modules/${{ github.repository }}
27+
28+
- name: Checkout modulesync configuration repository
29+
uses: actions/checkout@v2
30+
with:
31+
# TODO: is there a modulesync variable for this?
32+
repository: voxpupuli/modulesync_config
33+
ref: ${{ env.MSYNC_VER }}
34+
path: msync_config
35+
36+
- name: Create a temporary managed modules file
37+
run: echo "- $GITHUB_REPOSITORY" > msync_config/pr-managed-modules.yaml
38+
39+
- name: Setup ruby
40+
uses: ruby/setup-ruby@v1
41+
with:
42+
ruby-version: '3.0'
43+
bundler-cache: true
44+
working-directory: msync_config
45+
46+
- name: Run modulesync
47+
run: bundle exec msync update --offline --managed-modules-conf=pr-managed-modules.yaml --project-root=../modules
48+
working-directory: msync_config
49+
50+
- name: Check for differences
51+
run: git diff --exit-code
52+
working-directory: modules/${{ github.repository }}

0 commit comments

Comments
 (0)