|
| 1 | +name: build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ['*'] |
| 6 | + tags: |
| 7 | + - v* |
| 8 | + pull_request: |
| 9 | + type: [opened, reopened, edited] |
| 10 | + schedule: |
| 11 | + # run every night at midnight |
| 12 | + - cron: '0 0 * * *' |
| 13 | + |
| 14 | +jobs: |
| 15 | + unit: |
| 16 | + name: '${{matrix.name}} - puppet (${{matrix.puppet}})' |
| 17 | + runs-on: ubuntu-latest |
| 18 | + strategy: |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + # note: actions/setup-ruby only allows using a major.minor release of ruby |
| 23 | + - ruby: '2.5' |
| 24 | + puppet: "6.0" |
| 25 | + check: "check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" |
| 26 | + name: 'static' |
| 27 | + - ruby: '2.4' |
| 28 | + puppet: "5.0" |
| 29 | + check: "parallel_spec" |
| 30 | + name: 'spec' |
| 31 | + - ruby: '2.5' |
| 32 | + puppet: "6.0" |
| 33 | + check: "parallel_spec" |
| 34 | + name: 'spec' |
| 35 | + env: |
| 36 | + CHECK: '${{ matrix.check }}' |
| 37 | + PUPPET_GEM_VERSION: '~> ${{ matrix.puppet }}' |
| 38 | + # lock to 2.1.0 because 2.2.0 is causing issues during builds |
| 39 | + BUNDLER_GEM_VERSION: '~> 2.1.0' |
| 40 | + steps: |
| 41 | + - name: Checkout repository |
| 42 | + uses: actions/checkout@v2 |
| 43 | + - name: Setup Ruby |
| 44 | + uses: actions/setup-ruby@v1 |
| 45 | + with: |
| 46 | + ruby-version: '${{ matrix.ruby }}' |
| 47 | + - name: Bundle prep |
| 48 | + run: | |
| 49 | + gem install bundler -v "$BUNDLER_GEM_VERSION" |
| 50 | + bundle -v |
| 51 | + rm -f Gemfile.lock |
| 52 | + # Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" |
| 53 | + # See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" |
| 54 | + # Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" |
| 55 | + [ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION |
| 56 | + gem --version |
| 57 | + bundle -v |
| 58 | + bundle config path vendor/bundle |
| 59 | + bundle config without 'system_tests' |
| 60 | + bundle lock |
| 61 | + # restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists |
| 62 | + - uses: actions/cache@v2 |
| 63 | + with: |
| 64 | + path: vendor/bundle |
| 65 | + key: ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-test-${{ hashFiles('**/Gemfile.lock') }} |
| 66 | + restore-keys: | |
| 67 | + ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-test- |
| 68 | + - name: Bundle install |
| 69 | + run: | |
| 70 | + bundle install --jobs $(nproc) --retry 3 |
| 71 | + - name: Test |
| 72 | + run: 'bundle exec rake $CHECK' |
| 73 | + |
| 74 | + deploy: |
| 75 | + name: 'deploy to forge' |
| 76 | + needs: unit |
| 77 | + runs-on: ubuntu-latest |
| 78 | + # only run deploy on tags that start with 'v' |
| 79 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 80 | + # define a "strategy" here so we can use ruby/puppet as variables below |
| 81 | + strategy: |
| 82 | + fail-fast: false |
| 83 | + matrix: |
| 84 | + include: |
| 85 | + # note: actions/setup-ruby only allows using a major.minor release of ruby |
| 86 | + - ruby: '2.5' |
| 87 | + puppet: "6.0" |
| 88 | + env: |
| 89 | + PUPPET_GEM_VERSION: '~> ${{ matrix.puppet }}' |
| 90 | + # lock to 2.1.0 because 2.2.0 is causing issues during builds |
| 91 | + BUNDLER_GEM_VERSION: '~> 2.1.0' |
| 92 | + steps: |
| 93 | + - name: Checkout repository |
| 94 | + uses: actions/checkout@v2 |
| 95 | + - name: Setup Ruby |
| 96 | + uses: actions/setup-ruby@v1 |
| 97 | + with: |
| 98 | + ruby-version: '${{ matrix.ruby }}' |
| 99 | + - name: Bundle prep |
| 100 | + run: | |
| 101 | + gem install bundler -v "$BUNDLER_GEM_VERSION" |
| 102 | + bundle -v |
| 103 | + rm -f Gemfile.lock |
| 104 | + # Update system gems if requested. This is useful to temporarily workaround troubles in the test runner" |
| 105 | + # See https://github.com/puppetlabs/pdk-templates/commit/705154d5c437796b821691b707156e1b056d244f for an example of how this was used" |
| 106 | + # Ignore exit code of SIGPIPE'd yes to not fail with shell's pipefail set" |
| 107 | + [ -z "$RUBYGEMS_VERSION" ] || (yes || true) | gem update --system $RUBYGEMS_VERSION |
| 108 | + gem --version |
| 109 | + bundle -v |
| 110 | + bundle config path vendor/bundle |
| 111 | + bundle config without 'system_tests' |
| 112 | + bundle lock |
| 113 | + # restore cache AFTER doing 'bundle lock' so that Gemfile.lock exists |
| 114 | + - uses: actions/cache@v2 |
| 115 | + with: |
| 116 | + path: vendor/bundle |
| 117 | + key: ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-test-${{ hashFiles('**/Gemfile.lock') }} |
| 118 | + restore-keys: | |
| 119 | + ${{ runner.os }}-${{ matrix.puppet }}-${{ matrix.ruby }}-gems-test- |
| 120 | + - name: Bundle install |
| 121 | + run: | |
| 122 | + bundle install --jobs $(nproc) --retry 3 |
| 123 | + - name: Build and Deploy |
| 124 | + env: |
| 125 | + # TODO configure secrets here: |
| 126 | + # https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets |
| 127 | + BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}' |
| 128 | + BLACKSMITH_FORGE_PASSWORD: '${{ secrets.PUPPET_FORGE_PASSWORD }}' |
| 129 | + run: | |
| 130 | + bundle exec rake module:build |
| 131 | + bundle exec rake module:push |
| 132 | +
|
0 commit comments