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

Feature/initial solution #2

Merged
merged 45 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ea37a92
Initial commit when 1st unit test works.
miroslavpojer May 22, 2024
31f6376
- Implemented first unit tests
miroslavpojer May 22, 2024
ae3e21a
- Implemented all planned test to cover script logic.
miroslavpojer May 23, 2024
d115de2
- Removing dist dir from gitignore.
miroslavpojer May 23, 2024
75b6b58
- Added support for exclusion of root directories.x
miroslavpojer May 23, 2024
b958840
- Change in dist to add built index.js into commit.
miroslavpojer May 23, 2024
f2b95e8
- Debugging from CI PoV.
miroslavpojer May 23, 2024
1c78f9c
- Debugging from CI PoV.
miroslavpojer May 23, 2024
c7aa559
- Debugging from CI PoV.
miroslavpojer May 23, 2024
1d0b37e
- Debugging from CI PoV.
miroslavpojer May 23, 2024
75b56f4
- Debugging from CI PoV.
miroslavpojer May 23, 2024
ed9fc73
- Action solution migrated from JS to python solution.
miroslavpojer May 27, 2024
c3d8336
- Debugging CI controls.
miroslavpojer May 27, 2024
3000404
- Debugging CI controls.
miroslavpojer May 27, 2024
cf85cdd
- Debugging CI controls.
miroslavpojer May 27, 2024
d6d6d3b
- Debugging CI controls.
miroslavpojer May 27, 2024
c5c497e
- Remove local run script.
miroslavpojer May 27, 2024
ed65dbe
- Debugging CI controls.
miroslavpojer May 27, 2024
589beaa
- Reworked set-output solution to avoid deprecation.
miroslavpojer May 27, 2024
ae281b1
- Refactored test file to remove duplicities.
miroslavpojer May 27, 2024
16f67ad
- README.md up to date.
miroslavpojer May 28, 2024
6fb65bf
- Fix logical error.
miroslavpojer May 28, 2024
01f56a3
- Fix logical error.
miroslavpojer May 28, 2024
2a780f7
- Fixing non-deprecated solution for setting output.
miroslavpojer May 28, 2024
1fe614a
- Fix '-' vs '_'.
miroslavpojer May 28, 2024
eb6c47f
- Fix of issues.
miroslavpojer May 28, 2024
af786d7
- Fix of issues.
miroslavpojer May 28, 2024
f34d675
- Added last missing tests after set_output update.
miroslavpojer May 28, 2024
d19117d
- Fixing CI.
miroslavpojer May 28, 2024
cc3fe14
- Fixing CI.
miroslavpojer May 28, 2024
4d3b425
- Fixing CI.
miroslavpojer May 28, 2024
e3e930c
- Fixing CI.
miroslavpojer May 28, 2024
72ed572
- Fixing review comments.
miroslavpojer Jun 3, 2024
a52c31f
- Fixing review comments - renaming inputs
miroslavpojer Jun 4, 2024
c64474b
- Removed excludes_dir and renamed excluded_files to excludes.
miroslavpojer Jun 4, 2024
f4f9632
- Rename of input from 'include_directories' to 'paths'.
miroslavpojer Jun 4, 2024
16039bf
- Rework the set_output method.
miroslavpojer Jun 10, 2024
857e388
- BugFix from CI/CD testing of latest changes.
miroslavpojer Jun 10, 2024
d08c39d
- Introduced logging and removed info method.
miroslavpojer Jun 11, 2024
bd737a9
- Replace prints by logging.
miroslavpojer Jun 11, 2024
994f310
- Returned back the GH action concept of failing.
miroslavpojer Jun 11, 2024
57c06c9
- Final error logging for set_failed method.
miroslavpojer Jun 11, 2024
9b11bb9
- Removed file from paths example.
miroslavpojer Jun 11, 2024
f2f7ad3
- Reduced match methods.
miroslavpojer Jun 11, 2024
d722b4e
- Removed not used import.
miroslavpojer Jun 11, 2024
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
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit =
*/__init__.py
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @miroslavpojer @Zejnilovic
25 changes: 25 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Bug report
about: Create a report to help us improve
labels: 'bug'

---

## Describe the bug
A clear and concise description of what the bug is.

## To Reproduce
Steps to reproduce the behavior OR commands run:
1. Go to '...'
2. Click on '....'
3. Enter value '...'
4. See error

## Expected behavior
A clear and concise description of what you expected to happen.

## Screenshots
If applicable, add screenshots to help explain your problem.

## Additional context
Add any other context about the problem here.
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Feature request
about: Suggest an idea for this project
labels: 'enhancement'

---

## Background
A clear and concise description of where the limitation lies.

## Feature
A description of the requested feature.

## Example [Optional]
A simple example if applicable.

## Proposed Solution [Optional]
Solution Ideas:
1.
2.
3.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Question
about: Ask a question
labels: 'question'

---

## Background [Optional]
A clear explanation of the reason for raising the question.
This gives us a better understanding of your use cases and how we might accommodate them.

## Question
A clear and concise inquiry
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE/spike_task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Spike
about: Issue template for spikes, research and investigation tasks
labels: 'spike'

---

## Background
A clear and concise description of the problem or a topic we need to understand.

Feel free to add information about why it's needed and what assumptions you have at the moment.

## Questions To Answer

1.
2.
3.

## Desired Outcome

The list of desired outcomes of this spike ticket.

```[tasklist]
### Tasks
- [ ] Questions have been answered or we have a clearer idea of how to get to our goal
- [ ] Discussion with the team
- [ ] Documentation
- [ ] Create recommendations and new implementation tickets
- [ ] item here..
```

## Additional Info/Resources [Optional]

1.
2.
3.
43 changes: 43 additions & 0 deletions .github/workflows/check_pr_release_note_comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Check Release Notes in PR comment

on:
pull_request:
types: [opened, synchronize, reopened, edited, labeled, unlabeled]
branches: [ master ]

jobs:
check-release-notes-comments:
runs-on: ubuntu-latest
steps:
- name: Fetch all PR comments
id: get-comments
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueNumber = context.issue.number;
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;

const comments = await github.rest.issues.listComments({
owner: repoOwner,
repo: repoName,
issue_number: issueNumber,
});

return comments.data.map(comment => comment.body);

- name: Check for 'Release Notes' in comments
uses: actions/github-script@v7
with:
script: |
const comments = ${{ steps.get-comments.outputs.result }};
const releaseNotesRegex = /release notes/i;
const hasReleaseNotes = comments.some(comment => releaseNotesRegex.test(comment));

if (!hasReleaseNotes) {
console.log('No "Release notes" found in PR comments');
core.setFailed('No "Release notes" found in PR comments')
} else {
console.log('"Release notes" found in comments');
}
115 changes: 115 additions & 0 deletions .github/workflows/release_draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Release - create draft release
on:
workflow_dispatch:
inputs:
tagName:
description: 'Name of git tag to be created, and then draft release created. Syntax: "v[0-9]+.[0-9]+.[0-9]+".'
required: true

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Validate format of received tag
uses: actions/github-script@v7
with:
script: |
const newTag = core.getInput('tag-name');
const regex = /^v[0-9]+\.[0-9]+\.[0-9]+$/;

if (!regex.test(newTag)) {
core.setFailed('Tag does not match the required format "v[0-9]+.[0-9]+.[0-9]+"');
return;
}
tag-name: ${{ github.event.inputs.tagName }}

- name: Check tag's correct version increment
uses: actions/github-script@v7
with:
script: |
const newTag = core.getInput('tag-name');

// get latest tag
const { data: refs } = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'tags/'
});
console.log(`Existing tags: ${refs.map(ref => ref.ref.replace('refs/tags/', '')).join(', ')}`);

const latestTag = refs.sort((a, b) => new Date(b.object.date) - new Date(a.object.date))[0].ref.replace('refs/tags/', '');
console.log(`Latest tag: ${latestTag}`);

const latestVersion = latestTag.replace('v', '').split('.').map(Number);
const newVersion = newTag.replace('v', '').split('.').map(Number);

// check tag's correct version increase
const isValid = (latestVersion[0] === newVersion[0] && latestVersion[1] === newVersion[1] && newVersion[2] === latestVersion[2] + 1) ||
(latestVersion[0] === newVersion[0] && newVersion[1] === latestVersion[1] + 1 && newVersion[2] === 0) ||
(newVersion[0] === latestVersion[0] + 1 && newVersion[1] === 0 && newVersion[2] === 0);

if (!isValid) {
core.setFailed('New tag is not one version higher than the latest tag');
return;
}

tag-name: ${{ github.event.inputs.tagName }}

- name: Create and push tag
uses: actions/github-script@v7
with:
script: |
const tag = core.getInput('tag-name')
const ref = `refs/tags/${tag}`;
const sha = context.sha; // The SHA of the commit to tag

await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: ref,
sha: sha
});

console.log(`Tag created: ${tag}`);
github-token: ${{ secrets.GITHUB_TOKEN }}
tag-name: ${{ github.event.inputs.tagName }}

release:
needs: tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: refs/tags/${{ github.event.inputs.tagName }}

- name: Generate release notes
id: generate_release_notes
uses: AbsaOSS/generate-release-notes@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag-name: ${{ github.event.inputs.tagName }}
chapters: |
[
{"title": "Breaking Changes 💥", "label": "breaking-change"},
{"title": "New Features 🎉", "label": "feature"},
{"title": "New Features 🎉", "label": "enhancement"},
{"title": "Bugfixes 🛠", "label": "bug"}
]
warnings: true

- name: Create draft release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.event.inputs.tagName }}
body: ${{ steps.generate_release_notes.outputs.releaseNotes }}
tag_name: ${{ github.event.inputs.tagName }}
draft: true
prerelease: false
94 changes: 94 additions & 0 deletions .github/workflows/release_notes_comments_migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Copy Release Notes to Related Issues

on:
pull_request:
types: [closed]
branches: [ master ]

jobs:
copy_release_notes:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Fetch PR Comments
id: get-comments
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const prNumber = context.payload.pull_request.number;
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;
const releaseNotesRegex = /release notes/i;

const comments = await github.rest.issues.listComments({
owner: repoOwner,
repo: repoName,
issue_number: prNumber,
});

const releaseNoteComment = comments.data.find(comment => releaseNotesRegex.test(comment.body));
const releaseNoteBody = releaseNoteComment ? releaseNoteComment.body : '';
console.log(`Release Note Body: ${releaseNoteBody}`);
core.setOutput('releaseNoteBody', releaseNoteBody);

- name: Print Extracted releaseNoteBody
run: |
echo "Extracted Release Note Body:"
echo "${{ steps.get-comments.outputs.releaseNoteBody }}"
echo "RELEASE_NOTE_BODY<<EOF" >> $GITHUB_ENV
echo "${{ steps.get-comments.outputs.releaseNoteBody }}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV

- name: Parse PR Description for Related Issues
id: find-issues
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const description = context.payload.pull_request.body;
const issueNumbers = [];
const regexPattern = /([Cc]los(e|es|ed)|[Ff]ix(es|ed)?|[Rr]esolv(e|es|ed))\s*#\s*([0-9]+)/g;

let match;
while ((match = regexPattern.exec(description)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (match.index === regexPattern.lastIndex) {
regexPattern.lastIndex++;
}

// The actual issue number is in the last group of the match
const issueNumber = match[match.length - 1];
if (issueNumber) {
issueNumbers.push(issueNumber);
}
}

core.setOutput('issueNumbers', issueNumbers.join(', '));

- name: Print Extracted Issue Numbers
run: |
echo "Extracted Issue Numbers: ${{ steps.find-issues.outputs.issueNumbers }}"
echo "ISSUE_NUMBERS=${{ steps.find-issues.outputs.issueNumbers }}" >> $GITHUB_ENV

- name: Post Comment to Issues
if: ${{ steps.get-comments.outputs.releaseNoteBody }} && ${{ steps.find-issues.outputs.issueNumbers }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issueNumbers = process.env.ISSUE_NUMBERS;
const commentBody = process.env.RELEASE_NOTE_BODY;
const repoName = context.repo.repo;
const repoOwner = context.repo.owner;

for (const issueNumber of issueNumbers.split(', ')) {
if (issueNumber && commentBody) {
await github.rest.issues.createComment({
owner: repoOwner,
repo: repoName,
issue_number: issueNumber,
body: commentBody
});
}
}
20 changes: 20 additions & 0 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Run Unit Tests

on:
pull_request:

jobs:
run-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.x'
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Execute unit tests
run: |
pytest --cov=src --cov-report html tests/
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ __pycache__/
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
Expand Down Expand Up @@ -157,4 +156,9 @@ cython_debug/
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
node_modules
/package-lock.json
coverage
/violations.csv
/violations.json
Loading