kramdown-plantuml 1.0.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/codecov.yml +2 -0
  3. data/.github/dependabot.yml +23 -0
  4. data/.github/mergify.yml +22 -0
  5. data/.github/scripts/amend.sh +176 -0
  6. data/.github/scripts/build-gem.sh +6 -0
  7. data/.github/scripts/inspect-gem.sh +72 -0
  8. data/.github/scripts/publish-gem.sh +121 -0
  9. data/.github/scripts/test-gem.sh +170 -0
  10. data/.github/scripts/variables.sh +72 -0
  11. data/.github/workflows/amend.yml +19 -0
  12. data/.github/workflows/no-java.yml +3 -6
  13. data/.github/workflows/no-plantuml.yml +6 -9
  14. data/.github/workflows/ruby.yml +139 -86
  15. data/.github/workflows/shell.yml +11 -0
  16. data/.gitignore +9 -0
  17. data/.rubocop.yml +18 -0
  18. data/CODE_OF_CONDUCT.md +11 -9
  19. data/Gemfile +4 -8
  20. data/GitVersion.yml +5 -0
  21. data/LICENSE +201 -21
  22. data/README.md +143 -35
  23. data/Rakefile +33 -3
  24. data/bin/{plantuml.1.2020.5.jar → net/sourceforge/plantuml/plantuml/1.2021.8/plantuml-1.2021.8.jar} +0 -0
  25. data/kramdown-plantuml.gemspec +32 -17
  26. data/lib/kramdown-plantuml.rb +4 -6
  27. data/lib/kramdown-plantuml/bool_env.rb +24 -0
  28. data/lib/kramdown-plantuml/console_logger.rb +56 -0
  29. data/lib/kramdown-plantuml/converter.rb +39 -21
  30. data/lib/kramdown-plantuml/executor.rb +48 -0
  31. data/lib/kramdown-plantuml/hash.rb +14 -0
  32. data/lib/kramdown-plantuml/logger.rb +77 -0
  33. data/lib/kramdown-plantuml/plantuml_error.rb +33 -0
  34. data/lib/kramdown-plantuml/plantuml_result.rb +50 -0
  35. data/lib/kramdown-plantuml/themer.rb +64 -0
  36. data/lib/kramdown-plantuml/version.rb +3 -2
  37. data/lib/kramdown_html.rb +21 -9
  38. data/lib/which.rb +3 -0
  39. data/pom.xml +16 -0
  40. metadata +131 -12
  41. data/bin/console +0 -14
  42. data/bin/setup +0 -8
@@ -0,0 +1,72 @@
1
+ #!/bin/bash
2
+ set -o errexit # Abort if any command fails
3
+ me=$(basename "$0")
4
+
5
+ help_message="\
6
+ Usage: echo $me <version>
7
+ Generates variables based on the provided environment variable GITHUB_CONTEXT
8
+ and <version> argument.
9
+ GITHUB_CONTEXT: An environment variable containing a JSON string of the GitHub
10
+ context object. Typically generated with \${{ toJson(github) }}.
11
+ <version>: The version number corresponding to the current Git commit."
12
+
13
+ initialize() {
14
+ github_context_json="$GITHUB_CONTEXT"
15
+ version="$1"
16
+
17
+ if [[ -z "$github_context_json" ]]; then
18
+ echo "Missing or empty GITHUB_CONTEXT environment variable." >&2
19
+ echo "$help_message"
20
+ exit 1
21
+ fi
22
+
23
+ if [[ -z "$version" ]]; then
24
+ echo "No version specified." >&2
25
+ echo "$help_message"
26
+ exit 1
27
+ fi
28
+
29
+ sha=$(echo "$github_context_json" | jq --raw-output .sha)
30
+ ref=$(echo "$github_context_json" | jq --raw-output .ref)
31
+
32
+ if [[ -z "$sha" ]]; then
33
+ echo "No 'sha' found in the GitHub context." >&2
34
+ echo "$help_message"
35
+ exit 1
36
+ fi
37
+
38
+ if [[ -z "$ref" ]]; then
39
+ echo "No 'ref' found in the GitHub context." >&2
40
+ echo "$help_message"
41
+ exit 1
42
+ fi
43
+ }
44
+
45
+ generate_variables() {
46
+ # Replace '+'' in the version number with '.'.
47
+ version="${version//+/.}"
48
+ # Replace '-' in the version number with '.'.
49
+ version="${version//-/.}"
50
+
51
+ if [[ "$ref" == refs/tags/* ]]; then
52
+ # Override GitVersion's version on tags, just to be sure.
53
+ version="${ref#refs/tags/}"
54
+ fi
55
+
56
+ # Convert the version number to all-lowercase because GPR only supports lowercase version numbers.
57
+ version=$(echo "$version" | tr '[:upper:]' '[:lower:]')
58
+
59
+ echo "Ref: $ref"
60
+ echo "Sha: $sha"
61
+ echo "Version: $version"
62
+ echo "::set-output name=ref::$ref"
63
+ echo "::set-output name=sha::$sha"
64
+ echo "::set-output name=version::$version"
65
+ }
66
+
67
+ main() {
68
+ initialize "$@"
69
+ generate_variables
70
+ }
71
+
72
+ main "$@"
@@ -0,0 +1,19 @@
1
+ name: amend
2
+
3
+ on:
4
+ issue_comment:
5
+ types: [created]
6
+
7
+ jobs:
8
+ amend:
9
+ if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/amend')
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ persist-credentials: false
15
+ - name: amend
16
+ env:
17
+ GITHUB_TOKEN: ${{ secrets.PUBLIC_REPO_TOKEN }}
18
+ GITHUB_CONTEXT: ${{ toJSON(github) }}
19
+ run: .github/scripts/amend.sh --user payex-dev --verbose
@@ -8,18 +8,15 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- name: No Java
12
11
  runs-on: ubuntu-latest
13
12
  container:
14
- image: ruby:2.7.0-alpine3.11
13
+ image: ruby:2.7.2
15
14
 
16
15
  steps:
17
16
  - uses: actions/checkout@v2
18
17
 
19
18
  - name: Bundle install
20
- run: |
21
- find .
22
- bundle install --jobs 4 --retry 3
19
+ run: bundle install --jobs 4 --retry 3
23
20
 
24
- - name: Test with Rake
21
+ - name: RSpec
25
22
  run: bundle exec rspec --tag no_java
@@ -8,19 +8,16 @@ on:
8
8
 
9
9
  jobs:
10
10
  test:
11
- name: No PlantUML
12
11
  runs-on: ubuntu-latest
13
- container:
14
- image: ruby:2.7.0-alpine3.11
15
12
 
16
13
  steps:
17
14
  - uses: actions/checkout@v2
18
15
 
19
- - name: Bundle install
20
- run: bundle install --jobs 4 --retry 3
16
+ - name: Set up Ruby 2.7
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.7
20
+ bundler-cache: true
21
21
 
22
- - name: Remove plantuml.1.2020.5.jar
23
- run: rm bin/plantuml.1.2020.5.jar
24
-
25
- - name: Test with Rake
22
+ - name: RSpec
26
23
  run: bundle exec rspec --tag no_plantuml
@@ -1,123 +1,176 @@
1
1
  name: Ruby Gem
2
2
 
3
- on:
4
- push:
5
- branches:
6
- - '*'
7
- tags:
8
- - '*'
9
- pull_request:
3
+ on: [push, pull_request, pull_request_target]
10
4
 
11
5
  jobs:
12
- build:
13
- name: Build, Test and Publish Ruby Gem
6
+ version:
14
7
  runs-on: ubuntu-latest
15
8
 
9
+ outputs:
10
+ version: ${{ steps.variables.outputs.version }}
11
+
16
12
  steps:
17
13
  - uses: actions/checkout@v2
18
14
  with:
19
15
  fetch-depth: 0
20
16
 
21
- - name: Fetch all history for all tags and branches
22
- run: |
23
- git fetch --prune --tags
24
- echo "REF: ${{ github.ref }}"
25
-
26
- - name: Install GitVersion
27
- uses: gittools/actions/gitversion/setup@v0.9.2
28
- if: startsWith(github.ref, 'refs/tags/') != true # Only use GitVersion for unstable builds
17
+ - name: Setup GitVersion
18
+ uses: gittools/actions/gitversion/setup@v0.9.10
29
19
  with:
30
- versionSpec: '5.2.x'
20
+ versionSpec: '5.x.x'
31
21
 
32
22
  - name: Execute GitVersion
33
23
  id: gitversion
34
- if: startsWith(github.ref, 'refs/tags/') != true
35
- uses: gittools/actions/gitversion/execute@v0.9.2
24
+ uses: gittools/actions/gitversion/execute@v0.9.10
25
+
26
+ - name: Create variables
27
+ id: variables
28
+ env:
29
+ GITHUB_CONTEXT: ${{ toJson(github) }}
30
+ run: ./.github/scripts/variables.sh ${{ steps.gitversion.outputs.fullSemVer }}
31
+
32
+ plantuml:
33
+ needs: version
34
+ runs-on: ubuntu-latest
35
+
36
+ steps:
37
+ - uses: actions/checkout@v2
36
38
 
37
- - name: Create gem version number
38
- id: gemversion
39
- uses: actions/github-script@0.9.0
39
+ - name: Setup Java
40
+ uses: actions/setup-java@v2
40
41
  with:
41
- github-token: ${{ secrets.GITHUB_TOKEN }}
42
- script: |
43
- const gemVersion = (function() {
44
- const ref = '${{ github.ref }}';
45
- const tagPrefix = 'refs/tags/';
46
-
47
- if (ref.startsWith(tagPrefix)) {
48
- // If a tag ref is being built, just return the tag verbatim
49
- return ref.substring(tagPrefix.length);
50
- }
51
-
52
- const escapedBranchName = '${{ steps.gitversion.outputs.escapedBranchName }}';
53
- const commitsSinceVersionSource = '${{ steps.gitversion.outputs.commitsSinceVersionSourcePadded }}';
54
- const preReleaseLabel = escapedBranchName + '.' + commitsSinceVersionSource;
55
- const majorMinorPatch = '${{ steps.gitversion.outputs.majorMinorPatch }}';
56
- return majorMinorPatch + preReleaseLabel;
57
- })();
58
-
59
- core.debug('Gem version: ' + gemVersion);
60
- core.setOutput('version', gemVersion);
61
-
62
- - name: Set up Ruby 2.6
63
- uses: actions/setup-ruby@v1
42
+ distribution: adopt
43
+ java-version: 14
44
+
45
+ - name: Cache Maven dependencies
46
+ uses: actions/cache@v2.1.6
64
47
  with:
65
- ruby-version: 2.6.x
48
+ path: ~/.m2/repository
49
+ key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
50
+ restore-keys: ${{ runner.os }}-maven-
66
51
 
67
- - name: Setup Graphviz
68
- uses: kamiazya/setup-graphviz@v1
52
+ - name: Version stamp
53
+ run: mvn versions:set -DnewVersion=${{ needs.version.outputs.version }}
69
54
 
70
- - name: Cache dependencies
71
- uses: actions/cache@v1
55
+ - name: Maven install
56
+ run: mvn install
57
+
58
+ - name: Upload plantuml.jar artifact
59
+ uses: actions/upload-artifact@v2
72
60
  with:
73
- path: vendor/bundle
74
- key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
75
- restore-keys: ${{ runner.os }}-gems-
61
+ name: plantuml.jar
62
+ path: ~/.m2/repository/**/plantuml*.jar
63
+
64
+ gem:
65
+ needs: [version, plantuml]
66
+ runs-on: ubuntu-latest
76
67
 
77
- - name: Bundle install
78
- run: |
79
- gem install bundler
80
- bundle config path vendor/bundle
81
- bundle install --jobs 4 --retry 3
68
+ outputs:
69
+ name: ${{ steps.gem.outputs.name }}
70
+
71
+ steps:
72
+ - uses: actions/checkout@v2
73
+
74
+ - uses: actions/download-artifact@v2
75
+ with:
76
+ name: plantuml.jar
77
+ path: bin/
78
+
79
+ - name: Version stamp
80
+ run: sed -i -e 's/0.0.1.dev/${{ needs.version.outputs.version }}/g' ${{ github.workspace }}/lib/kramdown-plantuml/version.rb
81
+
82
+ - name: Setup Ruby 2.7
83
+ uses: ruby/setup-ruby@v1
84
+ with:
85
+ ruby-version: 2.7
86
+ bundler-cache: true
87
+
88
+ - name: Setup Graphviz
89
+ uses: kamiazya/setup-graphviz@v1
90
+
91
+ - name: rubocop
92
+ run: bundle exec rubocop --fail-level warning --display-only-fail-level-offenses
82
93
 
83
94
  - name: Test with Rake
84
- env:
85
- GEM_VERSION: ${{ steps.gemversion.outputs.version }}
86
95
  run: bundle exec rake
87
96
 
97
+ - name: RSPec (debug)
98
+ env:
99
+ DEBUG: 1
100
+ run: bundle exec rspec --tag debug
101
+
102
+ - name: Codecov upload
103
+ run: bundle exec rake codecov:upload || echo 'Codecov upload failed'
104
+
88
105
  - name: Build gem
89
106
  id: gem
90
- env:
91
- GEM_VERSION: ${{ steps.gemversion.outputs.version }}
92
- run: |
93
- GEM_BUILD_NAME=$(gem build kramdown-plantuml.gemspec | awk '/File/ {print $2}')
94
- echo "Gem filename: '${GEM_BUILD_NAME}'"
95
- echo "::set-output name=name::${GEM_BUILD_NAME}"
107
+ run: .github/scripts/build-gem.sh
96
108
 
97
- - name: Upload artifact
109
+ - name: Upload gem
98
110
  uses: actions/upload-artifact@v2-preview
99
111
  with:
100
112
  name: ${{ steps.gem.outputs.name }}
101
113
  path: ${{ steps.gem.outputs.name }}
102
114
 
115
+ - name: Inspect gem
116
+ run: .github/scripts/inspect-gem.sh --gem "${{ github.workspace }}/${{ steps.gem.outputs.name }}" --verbose
117
+
118
+ - name: Test gem
119
+ run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/fixture" --gemdir "${{ github.workspace }}" --verbose
120
+
121
+ publish-dev:
122
+ needs: [version, gem]
123
+ runs-on: ubuntu-latest
124
+ if: |
125
+ (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') ||
126
+ (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]')
127
+
128
+ steps:
129
+ - uses: actions/checkout@v2
130
+ if: ${{ github.event_name != 'pull_request_target' }}
131
+
132
+ - uses: actions/checkout@v2
133
+ if: ${{ github.event_name == 'pull_request_target' }}
134
+ with:
135
+ ref: ${{ github.event.pull_request.head.sha }}
136
+
137
+ - uses: actions/download-artifact@v2
138
+ with:
139
+ name: ${{ needs.gem.outputs.name }}
140
+
141
+ - name: Set up Ruby 2.7
142
+ uses: ruby/setup-ruby@v1
143
+ with:
144
+ ruby-version: 2.7
145
+ bundler-cache: true
146
+
147
+ - name: Setup Graphviz
148
+ uses: kamiazya/setup-graphviz@v1
149
+
103
150
  - name: Publish to GPR
104
- env:
105
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106
- OWNER: SwedbankPay
107
- run: |
108
- mkdir -p $HOME/.gem
109
- touch $HOME/.gem/credentials
110
- chmod 0600 $HOME/.gem/credentials
111
- printf -- "---\n:github: Bearer ${GITHUB_TOKEN}\n" > $HOME/.gem/credentials
112
- gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ${{ steps.gem.outputs.name }}
151
+ run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token "${{ secrets.GPR_TOKEN }}" --owner SwedbankPay --verbose
152
+
153
+ - name: Test gem
154
+ run: .github/scripts/test-gem.sh --workdir "${{ github.workspace }}/spec/fixture" --version ${{ needs.version.outputs.version }} --token "${{ secrets.GPR_TOKEN }}" --verbose
155
+
156
+ - name: Upload Jekyll site
157
+ uses: actions/upload-artifact@v2-preview
158
+ if: always()
159
+ with:
160
+ name: site
161
+ path: ${{ github.workspace }}/spec/fixture/_site
162
+
163
+ publish-prod:
164
+ needs: [version, gem]
165
+ runs-on: ubuntu-latest
166
+ if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits
167
+
168
+ steps:
169
+ - uses: actions/checkout@v2
170
+
171
+ - uses: actions/download-artifact@v2
172
+ with:
173
+ name: ${{ needs.gem.outputs.name }}
113
174
 
114
175
  - name: Publish to RubyGems
115
- if: startsWith(github.ref, 'refs/tags/') # Only publish tagged commits
116
- env:
117
- RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
118
- run: |
119
- mkdir -p $HOME/.gem
120
- touch $HOME/.gem/credentials
121
- chmod 0600 $HOME/.gem/credentials
122
- printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
123
- gem push ${{ steps.gem.outputs.name }}
176
+ run: .github/scripts/publish-gem.sh --gem ${{ needs.gem.outputs.name }} --token ${{ secrets.RUBYGEMS_API_KEY }} --verbose
@@ -0,0 +1,11 @@
1
+ name: Shell
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ shellcheck:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: ShellCheck
11
+ uses: bewuethr/shellcheck-action@v2
data/.gitignore CHANGED
@@ -8,3 +8,12 @@
8
8
  /tmp/
9
9
  *.gem
10
10
  Gemfile.lock
11
+ /target/
12
+ *.jar
13
+ /bin/
14
+ .jekyll-cache
15
+ _site
16
+ .classpath
17
+ .project
18
+ .settings
19
+ .vscode
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+ Exclude:
5
+ - "Rakefile"
6
+ - "_site/**/*.rb"
7
+ - "spec/**/*.rb"
8
+ - "vendor/**/.*"
9
+ - "vendor/**/*"
10
+ Layout:
11
+ LineLength: 100
12
+ IndentationStyle:
13
+ IndentationWidth: 2
14
+ Metrics/MethodLength:
15
+ Max: 20
16
+ Naming/FileName:
17
+ Exclude:
18
+ - 'lib/kramdown-plantuml.rb'