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

chore: Add initial workflows, licence and docs #9

Merged
merged 13 commits into from
Nov 11, 2024
Merged
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
13 changes: 13 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# The CODEOWNERS file defines individuals or teams that are
# responsible for code this repository.

# Code owners are automatically requested for review when someone opens a
# pull request that modifies code that they own.
# Code owners are not automatically requested to review draft pull requests
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in the repo.
# Unless a later match takes precedence, @krusche and @jpbernius will be
# requested for review when someone opens a pull request.

* @ls1intum/github-action-ui
39 changes: 39 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- Thanks for contributing to Helios! Before you submit your pull request, please make sure to check all tasks by putting an x in the [ ] (don't: [x ], [ x], do: [x]). Remove not applicable tasks and do not leave them unchecked -->
<!-- If your pull request is not ready for review yet, create a draft pull request! -->

### Motivation
<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->


### Description
<!-- Describe your changes in detail -->

### Testing Instructions
<!-- Please describe in detail how reviewers can test your changes. Make sure to take all related features and views into account! -->
#### Prerequisites:
- GitHub Account without having any additional access-rights (e.g. admin, owner)
- ...
#### Flow:
1. Log in to Helios as a Developer
2. Navigate to Settings
3. ...

### Screenshots
<!-- Add screenshots to demonstrate the changes in the UI. Remove the section if you did not change the UI. -->

### Checklist
<!-- Remove tasks that are not applicable for your PR. Please only put the PR into ready for review, if all relevant tasks are checked! -->
#### General
- [ ] PR description explains the purpose and changes. [(f.e. following the 'Conventional Commits')](https://www.conventionalcommits.org/en/v1.0.0/)
- [ ] Changes have been tested locally.
- [ ] Screenshots have been attached.

#### Server
- [ ] Code is performant and follows best practices
- [ ] I documented the Java code using JavaDoc style.

#### Client
- [ ] I documented the TypeScript code using JSDoc style.
- [ ] I added multiple screenshots/screencasts of my UI changes.
- [ ] I translated all newly inserted strings into English and German.
17 changes: 17 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
server:
- changed-files:
- any-glob-to-any-file: server/**

client:
- changed-files:
- any-glob-to-any-file: client/**

documentation:
- changed-files:
- any-glob-to-any-file: docs/**

feature:
- head-branch: ['^feature', '^feat']

bug:
- head-branch: ['^fix', '^bug']
47 changes: 47 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Documentation

on:
pull_request:
paths:
- 'docs/**'
- '.github/workflows/docs.yml'
push:
branches:
- main
paths:
- 'docs/**'
- '.github/workflows/docs.yml'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
docs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: FelixTJDietrich/sphinx-action@java
with:
docs-folder: "docs/"
build-command: make html dirhtml
- uses: actions/upload-artifact@v4
with:
name: Documentation
path: docs/_build/html/
- uses: actions/upload-pages-artifact@v3
with:
path: docs/_build/dirhtml/
deploy:
if: github.ref == 'refs/heads/main'
environment:
name: github-pages
url: "https://ls1intum.github.io/Helios/"
runs-on: ubuntu-22.04
needs: docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
92 changes: 92 additions & 0 deletions .github/workflows/pr-labeler.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: "Pull Request Labeler"
on:
pull_request_target:

jobs:
labeler:
name: "Apply labels"
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: "Checkout repository"
uses: actions/checkout@v4

- uses: actions/labeler@v5
with:
configuration-path: .github/labeler.yml
sync-labels: true

- name: "Apply size label"
uses: actions/github-script@v7
with:
script: |
console.log("Fetching pull request diff...");
const diff = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
mediaType: {
format: "diff",
},
});
console.log("Pull request diff fetched successfully.");

const changedLines = diff.data
.split("\n")
.filter(line => line.startsWith('+') || line.startsWith('-'))
.length;
console.log(`Number of changed lines: ${changedLines}`);

let label = '';
if (changedLines > 1000) label = 'size:XXL';
else if (changedLines > 499) label = 'size:XL';
else if (changedLines > 99) label = 'size:L';
else if (changedLines > 29) label = 'size:M';
else if (changedLines > 9) label = 'size:S';
else label = 'size:XS';

console.log("Fetching existing labels...");
const labels = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const sizeLabels = labels.data
.filter(label => label.name.startsWith('size:'))
.map(label => label.name);

const removeLabels = sizeLabels.filter(sizeLabel => sizeLabel !== label);
if (removeLabels.length > 0) {
console.log(`Removing existing size labels: ${removeLabels.join(', ')}`);
for (const label of removeLabels) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: label,
});
}
console.log("Existing size labels removed.");
} else {
console.log("No size labels to remove.");
}

if (label) {
if (sizeLabels.includes(label)) {
console.log(`Label "${label}" already applied.`);
} else {
console.log(`Applying label "${label}" to the pull request...`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [label]
});
console.log(`Label "${label}" applied successfully.`);
}
} else {
console.log("No label to apply.");
}
11 changes: 11 additions & 0 deletions .github/workflows/pullrequest-opened.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: Pull Request Opened
on:
pull_request_target:
types: [opened]

jobs:
assign:
runs-on: ubuntu-latest
steps:
- name: Assign Pull Request to its Author
uses: technote-space/assign-author@v1
20 changes: 20 additions & 0 deletions .github/workflows/pullrequest-readyforreview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Pull Request Ready for Review
on:
pull_request_target:
types: [ready_for_review]

jobs:
pullRequestReadyForReview:
runs-on: ubuntu-latest
steps:
- name: Label "ready for review"
uses: actions/github-script@v7
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['ready for review']
})
26 changes: 26 additions & 0 deletions .github/workflows/pullrequest-stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Stale
on:
schedule:
- cron: "0 12 * * *"

jobs:
stale:
if: github.repository_owner == 'ls1intum'
runs-on: ubuntu-latest
steps:
- name: Check for stale PRs
uses: actions/stale@v9
with:
days-before-stale: 7
days-before-close: 14
# Disable issue checking, only PR
days-before-issue-stale: -1
remove-stale-when-updated: true
stale-pr-label: "stale"
exempt-pr-labels: "no-stale"
labels-to-remove-when-stale: "ready for review"
stale-pr-message: >
There hasn't been any activity on this pull request recently.
Therefore, this pull request has been automatically marked as stale
and will be closed if no further activity occurs within **seven** days.
Thank you for your contributions.
Loading