Skip to content

Commit

Permalink
Add Dockerfile and GitHub actions for CI/releases
Browse files Browse the repository at this point in the history
  • Loading branch information
daaang committed Aug 22, 2024
1 parent 0637a31 commit 823874e
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 11 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "daily"
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Run CI"

on:
push:
branches: ["production"]
pull_request:
workflow_call:

jobs:
test:
runs-on: "ubuntu-latest"
strategy:
matrix:
task:
- "spec"
- "lint"
- "metadata_lint"
- "syntax"
- "rubocop"
steps:
- uses: "actions/checkout@v4"
- name: "rake ${{ matrix.task }}"
run: |
docker run --rm `docker build -q .` rake ${{ matrix.task }}
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "Release to Puppet Forge"

on: "workflow_dispatch"

jobs:
test:
uses: "./.github/workflows/ci.yml"

release:
runs-on: "ubuntu-latest"
needs: "test"
steps:
- uses: "actions/checkout@v4"
- name: "get version"
id: "get_version"
run: |
echo "version=`jq --raw-output .version metadata.json`" >> $GITHUB_OUTPUT
- name: "pdk build"
uses: "docker://puppet/pdk:3.0.0.0"
with:
args: "build"
- name: "gh changelog get --latest"
run: |
export GH_HOST=github.com
gh extension install chelnak/gh-changelog
gh changelog get --latest > OUTPUT.md
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: "gh release create"
run: |
gh release create v${{ steps.get_version.outputs.version }} --title v${{ steps.get_version.outputs.version }} -F OUTPUT.md
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: "pdk publish"
uses: "docker://puppet/pdk:3.0.0.0"
with:
args: "release publish --forge-token ${{ secrets.FORGE_API_KEY }} --force"
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ to [Semantic Versioning][2].
[1]: https://keepachangelog.com/en/1.1.0/
[2]: https://semver.org/spec/v2.0.0.html

## [0.1.0](https://github.com/mlibrary/puppet-$FORGE_MODULE_NAME/tree/v0.1.0) - YYYY-mm-dd
## [0.1.0](https://github.com/mlibrary/puppet-forge_module_name/tree/v0.1.0) - YYYY-mm-dd

### Added

Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ruby:3.3
RUN gem install bundler && mkdir -p /usr/src/app
COPY Gemfile* /usr/src/app
WORKDIR /usr/src/app
RUN bundle install
COPY . /usr/src/app
ENTRYPOINT ["bundle", "exec"]
CMD ["rake", "spec"]
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# FORGE_MODULE_NAME
# forge_module_name

Welcome to your new module. A short overview of the generated parts can be found
in the [PDK documentation][1].
Expand All @@ -9,10 +9,10 @@ information to include in your README.
## Table of Contents

1. [Description](#description)
1. [Setup - The basics of getting started with FORGE_MODULE_NAME](#setup)
* [What FORGE_MODULE_NAME affects](#what-FORGE_MODULE_NAME-affects)
1. [Setup - The basics of getting started with forge_module_name](#setup)
* [What forge_module_name affects](#what-forge_module_name-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with FORGE_MODULE_NAME](#beginning-with-FORGE_MODULE_NAME)
* [Beginning with forge_module_name](#beginning-with-forge_module_name)
1. [Usage - Configuration options and additional functionality](#usage)
1. [Limitations - OS compatibility, etc.](#limitations)
1. [Development - Guide for contributing to the module](#development)
Expand All @@ -27,7 +27,7 @@ is what they want.

## Setup

### What FORGE_MODULE_NAME affects **OPTIONAL**
### What forge_module_name affects **OPTIONAL**

If it's obvious what your module touches, you can skip this section. For
example, folks can probably figure out that your mysql_instance module affects
Expand All @@ -49,7 +49,7 @@ another module, etc.), mention it here.
If your most recent release breaks compatibility or requires particular steps
for upgrading, you might want to include an additional "Upgrading" section here.

### Beginning with FORGE_MODULE_NAME
### Beginning with forge_module_name

The very basic steps needed for a user to get the module up and running. This
can include setup steps, if necessary, or it can be an example of the most basic
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "mlibrary-$FORGE_MODULE_NAME",
"name": "mlibrary-forge_module_name",
"version": "0.1.0",
"author": "Regents of the University of Michigan",
"summary": "",
"license": "BSD-3-Clause",
"source": "https://github.com/mlibrary/puppet-$FORGE_MODULE_NAME",
"source": "https://github.com/mlibrary/puppet-forge_module_name",
"dependencies": [

],
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

default_fact_files = [
File.expand_path(File.join(File.dirname(__FILE__), 'default_facts.yml')),
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml')),
File.expand_path(File.join(File.dirname(__FILE__), 'default_module_facts.yml'))
]

default_fact_files.each do |f|
Expand Down Expand Up @@ -53,7 +53,7 @@
# Filter backtrace noise
backtrace_exclusion_patterns = [
%r{spec_helper},
%r{gems},
%r{gems}
]

if c.respond_to?(:backtrace_exclusion_patterns)
Expand Down

0 comments on commit 823874e

Please sign in to comment.