diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 97c5f5a9..65c1a9fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,61 +1,20 @@ +--- name: "ci" on: pull_request: - types: - - opened - - labeled - - synchronize branches: - "main" - paths-ignore: - - '**.md' - - 'examples/**' - - 'LICENSE' - - 'CODEOWNERS' - - 'AUTHORS' workflow_dispatch: - inputs: - debug: - description: "Debug" - type: boolean - required: false - default: true - run_spec: - description: "Run Spec job" - type: boolean - required: false - default: true - run_acceptance: - description: "Run Acceptance job" - type: boolean - required: false - default: false - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true jobs: - Matrix: - uses: ./.github/workflows/matrix.yml - with: - flags: "--exclude-platforms '[\"Ubuntu-18.04\"]'" # TODO: remove after postgres module update Spec: - if: ${{ github.event_name == 'pull_request' || inputs.run_spec == 'true' }} - needs: Matrix - uses: ./.github/workflows/module_spec.yml - secrets: inherit - with: - debug: ${{ github.events.inputs.debug == 'true' || contains(github.event.pull_request.labels.*.name, 'debug') }} - ignore_dependency_check: true # TODO: remove after module updates - matrix: ${{ needs.Matrix.outputs.spec_matrix }} + uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main" + secrets: "inherit" + Acceptance: - if: ${{ github.event_name == 'pull_request' || inputs.run_acceptance == 'true' }} - needs: [ Matrix, Spec ] - uses: ./.github/workflows/module_acceptance.yml - secrets: inherit + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" with: - debug: ${{ github.events.inputs.debug == 'true' || contains(github.event.pull_request.labels.*.name, 'debug') }} - matrix: ${{ needs.Matrix.outputs.acceptance_matrix }} - runs_on: ubuntu-20.04 # TODO: cgroupv1 containers do not provision on ubuntu-latest + runs_on: "ubuntu-20.04" diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml new file mode 100644 index 00000000..84b1d881 --- /dev/null +++ b/.github/workflows/labeller.yml @@ -0,0 +1,28 @@ +--- +name: Labeller + +on: + issues: + types: + - opened + - labeled + - unlabeled + pull_request_target: + types: + - opened + - labeled + - unlabeled + +jobs: + label: + runs-on: ubuntu-latest + steps: + + - uses: puppetlabs/community-labeller@v1.0.1 + name: Label issues or pull requests + with: + label_name: community + label_color: '5319e7' + org_membership: puppetlabs + fail_if_member: 'true' + token: ${{ secrets.IAC_COMMUNITY_LABELER }} diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml deleted file mode 100644 index ee9fdfaf..00000000 --- a/.github/workflows/matrix.yml +++ /dev/null @@ -1,49 +0,0 @@ ---- -on: - workflow_call: - inputs: - runs_on: - description: "The operating system used for the runner." - required: false - default: "ubuntu-latest" - type: "string" - flags: - description: "Additional flags to pass to matrix_from_metadata_v2." - required: false - default: '' - type: "string" - outputs: - spec_matrix: - description: "Spec matrix from metadata" - value: ${{ jobs.generate-json-matrix.outputs.spec_matrix }} - acceptance_matrix: - description: "Acceptance matrix from metadata" - value: ${{ jobs.generate-json-matrix.outputs.acceptance_matrix }} - -jobs: - generate-json-matrix: - name: Generate - runs-on: ${{ inputs.runs_on }} - outputs: - spec_matrix: ${{ steps.get-matrix.outputs.spec_matrix }} - acceptance_matrix: ${{ steps.get-matrix.outputs.matrix }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - name: Activate Ruby 2.7 - uses: ruby/setup-ruby@v1 - with: - ruby-version: "2.7" - bundler-cache: true - - name: Setup Test Matrix - id: get-matrix - run: | - bundle exec matrix_from_metadata_v2 ${{ inputs.flags }} - echo ::group::spec matrix - sed -n 's/^spec_matrix=\(.*\)/\1/p' $GITHUB_OUTPUT | jq - echo ::endgroup:: - echo ::group::acceptance matrix - sed -n 's/^matrix=\(.*\)/\1/p' $GITHUB_OUTPUT | jq - echo ::endgroup:: diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml new file mode 100644 index 00000000..08ade269 --- /dev/null +++ b/.github/workflows/mend.yml @@ -0,0 +1,16 @@ +--- +name: "mend" + +on: + pull_request_target: + types: + - opened + - synchronize + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + mend: + uses: "puppetlabs/cat-github-actions/.github/workflows/mend_ruby.yml@main" + secrets: "inherit" diff --git a/.github/workflows/module_acceptance.yml b/.github/workflows/module_acceptance.yml deleted file mode 100644 index 4d0a7439..00000000 --- a/.github/workflows/module_acceptance.yml +++ /dev/null @@ -1,125 +0,0 @@ -# This is a generic workflow for Puppet module acceptance operations. -name: "Module Acceptance" - -on: - workflow_call: - inputs: - matrix: - description: "JSON matrix" - type: "string" - required: true - debug: - description: "Run jobs with debug steps and flags enabled" - type: "boolean" - required: false - default: false - puppet_version: - description: "Version of Puppet used to run tests" - type: "string" - required: false - default: "~> 7.24" - ruby_version: - description: "Version of Ruby to install" - type: "string" - required: false - default: "2.7" - runs_on: - description: "The operating system used for the runner" - type: "string" - required: false - default: "ubuntu-latest" - -jobs: - Test: - name: "Test ${{ matrix.platforms.label }} with ${{ matrix.collection }}" - runs-on: ${{ inputs.runs_on }} - strategy: - fail-fast: false - matrix: ${{ fromJson(inputs.matrix) }} - env: - PUPPET_GEM_VERSION: ${{ inputs.puppet_version }} - FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' - BOLT_GEM: 1 - steps: - - name: Checkout Source - uses: actions/checkout@v4 - with: - fetch-depth: 1 - - - name: Activate Ruby ${{ inputs.ruby_version }} - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ inputs.ruby_version }} - bundler-cache: true - - - name: Debug - if: ${{ inputs.debug == true }} - run: | - echo ::group::bundler environment - bundle env - echo ::endgroup:: - echo ::group::docker info - docker info - echo ::endgroup:: - echo "RSPEC_DEBUG=1" >> $GITHUB_ENV - echo "DEBUG=1" >> $GITHUB_ENV - - - name: Cache fixture modules - id: cache-fixtures - uses: actions/cache@v4 - env: - cache-name: cache-fixtures-modules - with: - path: spec/fixtures/modules - key: test-${{ env.cache-name }}-${{ hashFiles('metadata.json', '.fixtures.yml') }} - restore-keys: | - test-${{ env.cache-name }}- - test- - - - name: Provision test environment - run: | - bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]' - FILE='spec/fixtures/litmus_inventory.yaml' - sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true - if [ "${{ inputs.debug }}" == "true" ] ; then - while read CN ; do - echo ::group::docker container $CN - docker inspect "$CN" - echo ::endgroup:: - done < <(docker ps --format '{{.Names}}') - fi - - - name: Install agent - run: | - echo ::group::agent - bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]' - echo ::endgroup:: - - - name: Install module - run: bundle exec rake 'litmus:install_module' - - - name: Run acceptance tests - id: run-acceptance - run: bundle exec rake 'litmus:acceptance' - - - name: Failure Logs - if: ${{ failure() && steps.run-acceptance.conclusion == 'failure' }} - continue-on-error: true - run: | - echo ::group::last 100 lines in runner journal - journalctl -n 100 - echo ::endgroup:: - echo ::group::last 100 lines in container journal - bundle exec bolt command run 'journalctl -n 100' -t all -i spec/fixtures/litmus_inventory.yaml - echo ::endgroup:: - echo ::group::last 50 lines of puppetlabs logs - bundle exec bolt command run 'tail -n 50 /var/log/puppetlabs/*/*.log' -t all -i spec/fixtures/litmus_inventory.yaml - echo ::endgroup:: - - - name: Tear down - if: ${{ always() }} - continue-on-error: true - run: | - if [[ -f spec/fixtures/litmus_inventory.yaml ]]; then - bundle exec rake 'litmus:tear_down' - fi diff --git a/.github/workflows/module_spec.yml b/.github/workflows/module_spec.yml deleted file mode 100644 index ca0ca25f..00000000 --- a/.github/workflows/module_spec.yml +++ /dev/null @@ -1,88 +0,0 @@ -# This is a generic workflow for Puppet module CI operations. -name: "Module Spec Matrix" - -on: - workflow_call: - inputs: - matrix: - description: "JSON matrix" - required: true - type: "string" - ignore_dependency_check: - description: "Ignore dependency check failure" - required: false - type: "boolean" - default: false - debug: - description: "Run jobs with debug steps and flags enabled" - required: false - type: "boolean" - default: false - runs_on: - description: "The operating system used for the runner" - required: false - default: "ubuntu-latest" - type: "string" - -jobs: - Test: - name: "Test Puppet ${{ matrix.puppet_version }} with ruby ${{ matrix.ruby_version }}" - runs-on: ${{ inputs.runs_on }} - strategy: - fail-fast: false - matrix: ${{ fromJson(inputs.matrix) }} - env: - PUPPET_GEM_VERSION: ${{ matrix.puppet_version }} - FACTER_GEM_VERSION: 'https://github.com/puppetlabs/facter#main' # why is this set? - - steps: - - name: "Checkout" - uses: "actions/checkout@v4" - with: - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 1 - - - name: "Setup ruby" - uses: "ruby/setup-ruby@v1" - with: - ruby-version: ${{ matrix.ruby_version }} - bundler-cache: true - - - name: Debug - if: ${{ inputs.debug == true }} - run: | - echo ::group::bundler environment - bundle env - echo ::endgroup:: - echo "RSPEC_DEBUG=1" >> $GITHUB_ENV - echo "DEBUG=1" >> $GITHUB_ENV - - - name: "Cache fixture modules" - id: cache-fixtures - uses: actions/cache@v4 - env: - cache-name: cache-fixtures-modules - with: - path: spec/fixtures/modules - key: test-${{ env.cache-name }}-${{ hashFiles('metadata.json', '.fixtures.yml') }} - restore-keys: | - test-${{ env.cache-name }}- - test- - - - name: "Run static & syntax tests" - run: bundle exec rake syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file strings:validate:reference rubocop - - - name: "Dependency check" - run: | - bundle exec dependency-checker metadata.json && EC=$? || EC=$? - if [ "${{ inputs.ignore_dependency_check }}" == "true" ] ; then - echo '::warning title=::ignoring dependency check failure' - else - exit $EC - fi - - - name: "Install modules" - run: bundle exec rake spec_prep - - - name: "Run tests" - run: bundle exec rake parallel_spec_standalone diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 00000000..163ce92f --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,19 @@ +--- +name: "nightly" + +on: + schedule: + - cron: "0 0 * * *" + workflow_dispatch: + +jobs: + Spec: + uses: "puppetlabs/cat-github-actions/.github/workflows/module_ci.yml@main" + secrets: "inherit" + + Acceptance: + needs: Spec + uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + secrets: "inherit" + with: + runs_on: "ubuntu-20.04" diff --git a/rakelib/common.rake b/rakelib/common.rake index 37d51254..00673c08 100644 --- a/rakelib/common.rake +++ b/rakelib/common.rake @@ -1,23 +1,18 @@ -require 'dependency_checker' -require 'metadata_json_lint' +begin + require 'metadata_json_lint' -# PDK validate behaviors -MetadataJsonLint.options.fail_on_warnings = true -MetadataJsonLint.options.strict_license = true -MetadataJsonLint.options.strict_puppet_version = true -MetadataJsonLint.options.strict_dependencies = true + # PDK validate behaviors + MetadataJsonLint.options.fail_on_warnings = true + MetadataJsonLint.options.strict_license = true + MetadataJsonLint.options.strict_puppet_version = true + MetadataJsonLint.options.strict_dependencies = true -PuppetLint.configuration.log_forat = '%{path}:%{line}:%{check}:%{KIND}:%{message}' -PuppetLint.configuration.fail_on_warnings = true -PuppetLint.configuration.ignore_paths.reject! { |c| c == 'spec/**/*.pp' } -PuppetLint.configuration.ignore_paths << 'spec/fixtures/**/*.pp' - -desc 'Run dependency-checker' -task :metadata_deps do - dpc = DependencyChecker::Runner.new - dpc.resolve_from_files(['metadata.json']) - dpc.run - raise 'dependency checker failed' unless dpc.problems.zero? + PuppetLint.configuration.log_forat = '%{path}:%{line}:%{check}:%{KIND}:%{message}' + PuppetLint.configuration.fail_on_warnings = true + PuppetLint.configuration.ignore_paths.reject! { |c| c == 'spec/**/*.pp' } + PuppetLint.configuration.ignore_paths << 'spec/fixtures/**/*.pp' +rescue LoadError + # ignore end # output task execution