From bf2c78e73a47c978a4bb630e6b3563715e05b323 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 13 Jul 2021 18:56:19 +0200 Subject: [PATCH] Add a job to warn about modulesync changes 01cfc20164bb4db5432b82d7a59e2227a718b240 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. --- .../.github/workflows/modulesync.yml.erb | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 moduleroot/.github/workflows/modulesync.yml.erb diff --git a/moduleroot/.github/workflows/modulesync.yml.erb b/moduleroot/.github/workflows/modulesync.yml.erb new file mode 100644 index 00000000..c9fe8af0 --- /dev/null +++ b/moduleroot/.github/workflows/modulesync.yml.erb @@ -0,0 +1,51 @@ +--- +# Managed by modulesync - DO NOT EDIT +# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/ + +name: CI + +on: pull_request + +jobs: + compare_with_repo: + name: 'Setup Test Matrix' + runs-on: ubuntu-latest + steps: + - name: Checkout Puppet module repository + uses: actions/checkout@v2 + path: modules/${{ env.github_repository }} + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + + - name: Set modulesync version + run: cat .msync.yml | ruby -ryaml -e 'puts "MSYNC_VER=#{YAML.load(STDIN)["modulesync_config_version"]}"' >> $GITHUB_ENV + working-directory: modules/${{ env.github_repository }} + + - name: Checkout modulesync configuration repository + uses: actions/checkout@v2 + # TODO: is there a modulesync variable for this? + repository: voxpupuli/modulesync_config + ref: ${{ env.MSYNC_VER }} + path: msync_config + + - name: Create a temporary managed modules file + run: echo "- $GITHUB_REPOSITORY" > msync_config/pr-managed-modules.yaml + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + path: msync_config + + - name: Run modulesync + run: bundle exec msync update --offline --managed-modules-conf=pr-managed-modules.yaml --project-root=../modules + working-directory: msync_config + + # TODO: does this actually fail the build? + - name: Check for differences + run: git diff + working-directory: modules/${{ env.github_repository }}