Skip to content

Commit

Permalink
ci: add danger for this project
Browse files Browse the repository at this point in the history
  • Loading branch information
tomassebestik committed Dec 1, 2023
1 parent 557ddf5 commit dd2d536
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 15 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/codebase-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Codebase-Tests
name: Codebase tests (Jest)

on:
pull_request:
Expand All @@ -10,17 +10,14 @@ on:
jobs:
codebase-tests:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Repository checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
Expand All @@ -30,7 +27,7 @@ jobs:
run: npm test

- name: Publish Test Report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: always()
with:
name: junit-report
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/danger-this.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: DangerJS (contributors)
on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
danger:
runs-on: ubuntu-latest
steps:
- name: Repository checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18.x'
cache: 'npm'

- name: Install dependencies
run: npm install --no-progress --no-update-notifier

- name: Run DangerJS
run: npx danger --dangerfile=src/dangerfile.ts ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTRIBUTING_GUIDE_FILE: 'CONTRIBUTING.md'
MAX_COMMITS: '7'
MAX_COMMITS_WARN: '9'
29 changes: 29 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pre-commit hooks CI
on:
pull_request:
types: [opened, edited, reopened, synchronize]
push:
branches: [ master ]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

- name: Install pre-commit
run: pip install pre-commit

- name: Run pre-commit on changed files
if: github.event_name == 'pull_request'
run: |
git fetch origin ${{ github.base_ref }}
git diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD ${{ github.base_ref }}) | xargs pre-commit run --files
env:
SKIP: "conventional-precommit-linter,eslint"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ This is the DangerJS pull request linter GitHub action, that can be called from
-TBD-
-TBD-
-TBD-

<!-- BADGES -->

![Codebase tests (Jest)](<https://github.com/espressif/shared-github-dangerjs/workflows/Codebase%20tests%20(Jest)/badge.svg>)
7 changes: 3 additions & 4 deletions src/outputInstructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ export default async function (): Promise<void> {

// Contributors guide link, if exists in the repository
if (config.instructions.contributingGuideFile) {
const contributionsGuideLink = `https://github.com/${repositoryOwner}/${repositoryName}/blob/${await getDefaultBranch()}/${
config.instructions.contributingGuideFile
}`;
const defaultBranch = await getDefaultBranch();
const contributionsGuideLink = `https://github.com/${repositoryOwner}/${repositoryName}/blob/${defaultBranch}/${config.instructions.contributingGuideFile}`;
instructions += `<hr>`;
instructions += `📘 Please review the project's <a href="${contributionsGuideLink}}">Contributions Guide</a> for key guidelines on code, documentation, testing, and more.<br>`;
instructions += `📘 Please review the project's <a href="${contributionsGuideLink}">Contributions Guide</a> for key guidelines on code, documentation, testing, and more.<br>`;
}

// Contributor License Agreement, if provided link to it
Expand Down

0 comments on commit dd2d536

Please sign in to comment.