Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC Use github workflow services by setting correct docker opts #105

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
fixtures:
repositories:
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
apt: "https://github.com/puppetlabs/puppetlabs-apt.git"
docker: "https://github.com/puppetlabs/puppetlabs-docker.git"
stdlib: https://github.com/puppetlabs/puppetlabs-stdlib.git
apt: https://github.com/puppetlabs/puppetlabs-apt.git
docker: https://github.com/puppetlabs/puppetlabs-docker.git
ruby_task_helper: https://github.com/puppetlabs/puppetlabs-ruby_task_helper.git
translate: https://github.com/puppetlabs/puppetlabs-translate.git
yumrepo_core:
repo: https://github.com/puppetlabs/puppetlabs-yumrepo_core.git
puppet_version: ">= 6.0.0"
9 changes: 5 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ By participating in this project you agree to abide by its terms.

Please be prepared to repeat some of these steps as our contributors review your code.

Also consider sending in your profile code that calls this component module as an acceptance test or provide it via an issue. This helps reviewers a lot to test your use case and prevents future regressions!

## Writing proper commits - short version

* Make commits of logical units.
Expand Down Expand Up @@ -230,14 +232,14 @@ simple tests against it after applying the module. You can run this
with:

```sh
bundle exec rake acceptance
bundle exec rake beaker
```

This will run the tests on the module's default nodeset. You can override the
nodeset used, e.g.,

```sh
BEAKER_set=centos-7-x64 bundle exec rake acceptance
BEAKER_set=centos-7-x64 bundle exec rake beaker
```

There are default rake tasks for the various acceptance test modules, e.g.,
Expand All @@ -264,10 +266,9 @@ The following strings are known to work:

* ubuntu1604
* ubuntu1804
* debian8
* ubuntu2004
* debian9
* debian10
* centos6
* centos7
* centos8

Expand Down
84 changes: 84 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI

on: pull_request

jobs:
setup_matrix:
name: 'Setup Test Matrix'
runs-on: ubuntu-latest
outputs:
beaker_setfiles: ${{ steps.get-outputs.outputs.beaker_setfiles }}
puppet_major_versions: ${{ steps.get-outputs.outputs.puppet_major_versions }}
puppet_unit_test_matrix: ${{ steps.get-outputs.outputs.puppet_unit_test_matrix }}
env:
BUNDLE_WITHOUT: development:test:release
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Run rake validate
run: bundle exec rake validate
- name: Setup Test Matrix
id: get-outputs
run: bundle exec metadata2gha --use-fqdn --pidfile-workaround false

unit:
needs: setup_matrix
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include: ${{fromJson(needs.setup_matrix.outputs.puppet_unit_test_matrix)}}
env:
BUNDLE_WITHOUT: development:system_tests:release
PUPPET_VERSION: "~> ${{ matrix.puppet }}.0"
name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Create task helper symlink
run: ln -s puppet-gitlab_ci_runner/spec/fixtures/modules/ruby_task_helper ../
- name: Run tests
run: bundle exec rake

acceptance:
needs: setup_matrix
runs-on: ubuntu-latest
env:
BUNDLE_WITHOUT: development:test:release
strategy:
fail-fast: false
matrix:
setfile: ${{fromJson(needs.setup_matrix.outputs.beaker_setfiles)}}
puppet: ${{fromJson(needs.setup_matrix.outputs.puppet_major_versions)}}
name: ${{ matrix.puppet.name }} - ${{ matrix.setfile.name }}
services:
gitlab:
image: gitlab/gitlab-ce
ports:
- 80:80
steps:
- uses: actions/checkout@v2
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Set Gitlab variables
run: |
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${{ job.services.gitlab.id }} > ~/GITLAB_IP
echo 'puts "INSTANCE TOKEN: #{Gitlab::CurrentSettings.current_application_settings.runners_registration_token}"' | \
docker exec -i ${{ job.services.gitlab.id }} gitlab-rails console | \
awk '/^INSTANCE TOKEN:/ {print $NF}' > ~/INSTANCE_TOKEN
- name: Run tests
run: bundle exec rake beaker
env:
BEAKER_PUPPET_COLLECTION: ${{ matrix.puppet.collection }}
BEAKER_setfile: 'centos7-64{hypervisor=docker,hostname=centos7-64.example.com,dockeropts={HostConfig={NetworkMode=${{ job.services.gitlab.network }}}}}'
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release

on:
push:
tags:
- '*'

env:
BUNDLE_WITHOUT: development:test:system_tests

jobs:
deploy:
name: 'deploy to forge'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.7'
bundler-cache: true
- name: Build and Deploy
env:
# Configure secrets here:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets
BLACKSMITH_FORGE_USERNAME: '${{ secrets.PUPPET_FORGE_USERNAME }}'
BLACKSMITH_FORGE_API_KEY: '${{ secrets.PUPPET_FORGE_API_KEY }}'
run: bundle exec rake module:push
3 changes: 2 additions & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
modulesync_config_version: '3.0.0'
---
modulesync_config_version: '4.0.0'
2 changes: 1 addition & 1 deletion .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ PrePush:
- 'validate'
- 'test'
- 'rubocop'
command: [ 'bundle', 'exec', 'rake' ]
command: ['bundle', 'exec', 'rake']
17 changes: 15 additions & 2 deletions .pmtignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,34 @@
docs/
pkg/
Gemfile
Gemfile.lock
Gemfile.local
vendor/
.vendor/
spec/fixtures/manifests/
spec/fixtures/modules/
spec/
Rakefile
.vagrant/
.bundle/
.ruby-version
coverage/
log/
.idea/
.dependencies/
.github/
.librarian/
Puppetfile.lock
*.iml
.editorconfig
.fixtures.yml
.gitignore
.msync.yml
.overcommit.yml
.pmtignore
.rspec
.rspec_parallel
.rubocop.yml
.sync.yml
.*.sw?
.yardoc/
.yardopts
Dockerfile
Loading