Skip to content

Commit 7703def

Browse files
committed
Improve safety in GitHub actions
1 parent 9a533e6 commit 7703def

13 files changed

Lines changed: 259 additions & 301 deletions

.github/workflows/build-and-snapshot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- cron: "0 0 * * 0" # Weekly on Sunday at midnight
1111
workflow_dispatch: # Allows manual triggering
1212

13+
permissions:
14+
contents: read
15+
1316
jobs:
1417
lint-and-test-python:
1518
name: Lint Python Test Suite
@@ -92,6 +95,8 @@ jobs:
9295
needs: [build, lint-and-test-python]
9396
runs-on: ubuntu-latest
9497
if: (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && (needs.lint-and-test-python.result == 'success' || needs.lint-and-test-python.result == 'skipped')
98+
permissions:
99+
contents: write
95100

96101
steps:
97102
- name: Checkout code
@@ -133,6 +138,12 @@ jobs:
133138
id: timestamp
134139
run: echo "timestamp=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
135140

141+
- name: Get JStall version
142+
id: jstall
143+
run: |
144+
JSTALL_VERSION=$(curl -s https://api.github.com/repos/parttimenerd/jstall/releases/latest | python3 -c "import sys,json; print(json.load(sys.stdin).get('tag_name','unknown'))")
145+
echo "version=$JSTALL_VERSION" >> $GITHUB_OUTPUT
146+
136147
- uses: thomashampson/delete-older-releases@main
137148
with:
138149
keep_latest: 0
@@ -168,6 +179,11 @@ jobs:
168179
169180
**Build Timestamp**: ${{ steps.timestamp.outputs.timestamp }}
170181
182+
**Bundled JStall version**: [${{ steps.jstall.outputs.version }}](https://github.com/parttimenerd/jstall/releases/tag/${{ steps.jstall.outputs.version }})
183+
184+
> **Tip:** You can also use a newer JStall version directly via `jstall --cf APP_NAME COMMAND`
185+
> (see [JStall README](https://github.com/parttimenerd/jstall#usage)).
186+
171187
## Installation
172188
173189
Download the current snapshot release and install manually:

.github/workflows/plugin-repo.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
generate-plugin-repo:
912
name: Generate Plugin Repository YAML

.github/workflows/pr-validation.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
- master
88

9+
permissions:
10+
contents: read
11+
912
jobs:
1013
validate-pr:
1114
name: Validate Pull Request

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ jobs:
9999
VERSION="${{ github.event.inputs.version }}"
100100
IFS='.' read -r MAJOR MINOR BUILD <<< "$VERSION"
101101
102+
# Determine the bundled JStall version
103+
export JSTALL_VERSION=$(curl -s https://api.github.com/repos/parttimenerd/jstall/releases/latest | python3 -c "import sys,json; print(json.load(sys.stdin).get('tag_name','unknown'))")
104+
echo "Bundled JStall version: $JSTALL_VERSION"
105+
102106
echo "Updating version to $MAJOR.$MINOR.$BUILD"
107+
source venv/bin/activate
103108
python3 .github/workflows/update_version.py "$MAJOR" "$MINOR" "$BUILD"
104109
105110
# Configure git

.github/workflows/update_version.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@
66

77
import sys
88
import re
9+
import os
910
from pathlib import Path
1011

12+
try:
13+
import requests
14+
HAS_REQUESTS = True
15+
except ImportError:
16+
HAS_REQUESTS = False
17+
1118
def update_version_in_go_file(file_path, major, minor, build):
1219
"""Update the version in the Go plugin metadata."""
1320
with open(file_path, 'r') as f:
@@ -76,12 +83,41 @@ def is_rc_version(version_str):
7683
"""Return True if the version string ends with -rc or -rcN."""
7784
return bool(re.match(r"^\d+\.\d+\.\d+-rc(\d+)?$", version_str))
7885

86+
def get_jstall_version():
87+
"""Get the bundled JStall version from the GitHub API or environment variable."""
88+
# Check environment variable first (set by CI workflow)
89+
env_version = os.environ.get("JSTALL_VERSION")
90+
if env_version:
91+
return env_version
92+
93+
# Fall back to querying the GitHub API
94+
if HAS_REQUESTS:
95+
try:
96+
resp = requests.get(
97+
"https://api.github.com/repos/parttimenerd/jstall/releases/latest",
98+
timeout=10
99+
)
100+
if resp.status_code == 200:
101+
return resp.json().get("tag_name", "")
102+
except Exception:
103+
pass
104+
105+
return ""
106+
107+
79108
def generate_release_notes(version, changelog_content):
80109
"""Generate complete release notes file."""
110+
jstall_version = get_jstall_version()
111+
jstall_note = ""
112+
if jstall_version:
113+
jstall_note = f"\n**Bundled JStall version**: [{jstall_version}](https://github.com/parttimenerd/jstall/releases/tag/{jstall_version})\n"
114+
jstall_note += "\n> **Tip:** You can also use a newer JStall version directly via `jstall --cf APP_NAME COMMAND` "
115+
jstall_note += "(see [JStall README](https://github.com/parttimenerd/jstall#usage)).\n"
116+
81117
release_notes = f"""## CF CLI Java Plugin {version}
82118
83119
Plugin for profiling Java applications and getting heap and thread-dumps.
84-
120+
{jstall_note}
85121
## Changes
86122
87123
{changelog_content}

.markdownlint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
"code_blocks": false,
66
"tables": false
77
},
8+
"MD024": {
9+
"siblings_only": true
10+
},
811
"MD033": false,
912
"MD041": false,
1013
"MD046": {

CHANGELOG.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,40 @@
22

33
All notable changes to this project will be documented in this file.
44

5-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to
6+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

1010
### Added
11-
- Bundle [jstall](https://github.com/parttimenerd/jstall) (jstall-minimal.jar) for one-shot JVM inspection
12-
via `cf java jstall APP_NAME`. Requires Java 17+ locally. Supports all jstall subcommands via `jstall APP --args`.
11+
12+
- Bundle [jstall](https://github.com/parttimenerd/jstall) (jstall-minimal.jar) for one-shot JVM inspection via
13+
`cf java jstall APP_NAME`. Requires Java 17+ locally. Supports all jstall subcommands via `jstall APP --args`.
1314

1415
### Changed
16+
1517
- Improved SSH error messages for better clarity and debugging
1618
- Enhanced documentation and README with better clarity
1719

1820
## [4.0.2]
1921

2022
### Fixed
23+
2124
- Fix rare ssh connection issue
2225

2326
## [4.0.1]
2427

2528
### Fixed
29+
2630
- Fix thread-dump command
2731

2832
## [4.0.0]
2933

3034
### Added
35+
3136
- Create a proper test suite
3237
- Profiling and JCMD related features
3338

3439
### Fixed
40+
3541
- Fix many bugs discovered during testing

CONTRIBUTING.md

Lines changed: 51 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,41 @@
11
# Contributing
22

3-
When contributing to this repository, please first discuss the change you wish to make via issue before making a
4-
change. We restrict the scope of this plugin to keep it maintainable.
3+
When contributing to this repository, please first discuss the change you wish to make via issue before making a change.
4+
We restrict the scope of this plugin to keep it maintainable.
55

66
We have a [code of conduct](#code-of-conduct), please follow it in all your interactions with the project.
77

88
## Contribute Code
99

10-
You are welcome to contribute code to the Cloud Foundry CLI Java Plugin in order to fix bugs or to implement new features.
10+
You are welcome to contribute code to the Cloud Foundry CLI Java Plugin in order to fix bugs or to implement new
11+
features.
1112

1213
There are three important things to know:
1314

1415
1. You must be aware of the Apache License (which describes contributions) and agree to the Contributors License
15-
Agreement (CLA). This is common practice in all major Open Source projects.
16-
To make this process as simple as possible, we are using the [CLA assistant](https://cla-assistant.io/) for
17-
individual contributions.
18-
CLA assistant is an open source tool that integrates with GitHub very well and enables a one-click-experience
19-
for accepting the CLA.
16+
Agreement (CLA). This is common practice in all major Open Source projects. To make this process as simple as
17+
possible, we are using the [CLA assistant](https://cla-assistant.io/) for individual contributions. CLA assistant is
18+
an open source tool that integrates with GitHub very well and enables a one-click-experience for accepting the CLA.
2019
For company contributors, special rules apply.
2120
2. We set ourselves requirements regarding code style and quality, and we kindly ask you to do the same with PRs.
22-
3. Not all proposed contributions can be accepted.
23-
Some features may, for example, just fit a separate plugin better.
24-
The code must fit the overall direction of Cloud Foundry CLI Java Plugin and really improve it, so there should
25-
be some "bang for the byte".
26-
For most bug fixes this is a given, but it would be advisable to first discus new major features with the
27-
maintainers by opening an issue on the project.
21+
3. Not all proposed contributions can be accepted. Some features may, for example, just fit a separate plugin better.
22+
The code must fit the overall direction of Cloud Foundry CLI Java Plugin and really improve it, so there should be
23+
some "bang for the byte". For most bug fixes this is a given, but it would be advisable to first discus new major
24+
features with the maintainers by opening an issue on the project.
2825

2926
### Pull Request Process
3027

3128
This a checklist of things to keep in your mind when opening pull requests for this project.
3229

3330
1. Make sure you have accepted the [Developer Certificate of Origin](#developer-certificate-of-origin-dco)
3431
2. Make sure any added dependency is licensed under Apache v2.0 license
35-
3. Strive for very high unit-test coverage and favor testing productive code over mocks
36-
(mock in depth wherever possible)
32+
3. Strive for very high unit-test coverage and favor testing productive code over mocks (mock in depth wherever
33+
possible)
3734
4. Update the README.md with details of changes to the options
3835

3936
Pull requests will be tested and validated by maintainers. In case small changes are needed (e.g., correcting typos),
40-
the maintainers may fix those issues themselves.
41-
In case of larger issues, you may be asked to apply modifications to your changes before the Pull Request can be merged.
37+
the maintainers may fix those issues themselves. In case of larger issues, you may be asked to apply modifications to
38+
your changes before the Pull Request can be merged.
4239

4340
### Developer Certificate of Origin (DCO)
4441

@@ -52,80 +49,68 @@ As artificial intelligence evolves, AI-generated code is becoming valuable for m
5249
open-source initiatives. While we recognize the potential benefits of incorporating AI-generated content into our
5350
open-source projects there a certain requirements that need to be reflected and adhered to when making contributions.
5451

55-
Please see our [guideline for AI-generated code contributions to SAP Open Source Software Projects](CONTRIBUTING_USING_GENAI.md)
56-
for these requirements.
52+
Please see our
53+
[guideline for AI-generated code contributions to SAP Open Source Software Projects](CONTRIBUTING_USING_GENAI.md) for
54+
these requirements.
5755

5856
## Code of Conduct
5957

6058
### Our Pledge
6159

62-
In the interest of fostering an open and welcoming environment, we as
63-
contributors and maintainers pledge to making participation in our project and
64-
our community a harassment-free experience for everyone, regardless of age, body
65-
size, disability, ethnicity, gender identity and expression, level of experience,
66-
nationality, personal appearance, race, religion, or sexual identity and
67-
orientation.
60+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
61+
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
62+
disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race,
63+
religion, or sexual identity and orientation.
6864

6965
### Our Standards
7066

71-
Examples of behavior that contributes to creating a positive environment
72-
include:
67+
Examples of behavior that contributes to creating a positive environment include:
7368

74-
* Using welcoming and inclusive language
75-
* Being respectful of differing viewpoints and experiences
76-
* Gracefully accepting constructive criticism
77-
* Focusing on what is best for the community
78-
* Showing empathy towards other community members
69+
- Using welcoming and inclusive language
70+
- Being respectful of differing viewpoints and experiences
71+
- Gracefully accepting constructive criticism
72+
- Focusing on what is best for the community
73+
- Showing empathy towards other community members
7974

8075
Examples of unacceptable behavior by participants include:
8176

82-
* The use of sexualized language or imagery and unwelcome sexual attention or
83-
advances
84-
* Trolling, insulting/derogatory comments, and personal or political attacks
85-
* Public or private harassment
86-
* Publishing others' private information, such as a physical or electronic
87-
address, without explicit permission
88-
* Other conduct which could reasonably be considered inappropriate in a
89-
professional setting
77+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
78+
- Trolling, insulting/derogatory comments, and personal or political attacks
79+
- Public or private harassment
80+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
81+
- Other conduct which could reasonably be considered inappropriate in a professional setting
9082

9183
### Our Responsibilities
9284

93-
Project maintainers are responsible for clarifying the standards of acceptable
94-
behavior and are expected to take appropriate and fair corrective action in
95-
response to any instances of unacceptable behavior.
85+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
86+
appropriate and fair corrective action in response to any instances of unacceptable behavior.
9687

97-
Project maintainers have the right and responsibility to remove, edit, or
98-
reject comments, commits, code, wiki edits, issues, and other contributions
99-
that are not aligned to this Code of Conduct, or to ban temporarily or
100-
permanently any contributor for other behaviors that they deem inappropriate,
101-
threatening, offensive, or harmful.
88+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
89+
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
90+
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
10291

10392
### Scope
10493

105-
This Code of Conduct applies both within project spaces and in public spaces
106-
when an individual is representing the project or its community. Examples of
107-
representing a project or community include using an official project e-mail
108-
address, posting via an official social media account, or acting as an appointed
109-
representative at an online or offline event. Representation of a project may be
110-
further defined and clarified by project maintainers.
94+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
95+
project or its community. Examples of representing a project or community include using an official project e-mail
96+
address, posting via an official social media account, or acting as an appointed representative at an online or offline
97+
event. Representation of a project may be further defined and clarified by project maintainers.
11198

11299
### Enforcement
113100

114-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
115-
reported by contacting the project team at [sap_cp_performance [at] sap.com](mailto:sap_cp_performance@sap.com). All
116-
complaints will be reviewed and investigated and will result in a response that
117-
is deemed necessary and appropriate to the circumstances. The project team is
118-
obligated to maintain confidentiality with regard to the reporter of an incident.
119-
Further details of specific enforcement policies may be posted separately.
101+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at
102+
[sap_cp_performance [at] sap.com](mailto:sap_cp_performance@sap.com). All complaints will be reviewed and investigated
103+
and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is
104+
obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific
105+
enforcement policies may be posted separately.
120106

121-
Project maintainers who do not follow or enforce the Code of Conduct in good
122-
faith may face temporary or permanent repercussions as determined by other
123-
members of the project's leadership.
107+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
108+
repercussions as determined by other members of the project's leadership.
124109

125110
### Attribution
126111

127-
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
128-
available at [http://contributor-covenant.org/version/1/4][version]
112+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at
113+
[http://contributor-covenant.org/version/1/4][version]
129114

130115
[homepage]: http://contributor-covenant.org
131116
[version]: http://contributor-covenant.org/version/1/4/

0 commit comments

Comments
 (0)