Skip to content

Commit

Permalink
Merge branch 'hannibal002:beta' into CakeTracker
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidArthurCole authored Aug 17, 2024
2 parents 4a862de + c5c6471 commit 2694845
Show file tree
Hide file tree
Showing 129 changed files with 2,371 additions and 635 deletions.
71 changes: 71 additions & 0 deletions .github/scripts/checkDependencies.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import {Octokit} from "@octokit/rest";
import fetch from "node-fetch";

const labelName = "Waiting on Dependency PR";

async function run() {
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
request: {
fetch: fetch,
},
});

const context = JSON.parse(process.env.GITHUB_CONTEXT);

const pull_request = context.event.pull_request;

const owner = context.repository_owner;
const name = context.repository.split("/")[1];

const prNumber = pull_request.number;
const prBody = pull_request.body || "";

const dependencyRegex = /## Dependencies/;
const match = prBody.match(dependencyRegex);

if (match) {
const prLinks = prBody.match(/- https:\/\/github\.com\/[\w-]+\/[\w-]+\/pull\/\d+/g);

if (prLinks && prLinks.length > 0) {
let hasOpenDependencies = false;

for (const link of prLinks) {
const [, depOwner, depRepo, depNumber] = link.match(/github\.com\/([\w-]+)\/([\w-]+)\/pull\/(\d+)/);
const {data: dependencyPr} = await octokit.pulls.get({
owner: depOwner,
repo: depRepo,
pull_number: depNumber,
});

if (dependencyPr.state === "open") {
hasOpenDependencies = true;
break;
}
}

const labels = pull_request.labels.map(label => label.name);

if (hasOpenDependencies && !labels.includes(labelName)) {
await octokit.issues.addLabels({
owner,
repo: name,
issue_number: prNumber,
labels: [labelName],
});
} else if (!hasOpenDependencies && labels.includes(labelName)) {
await octokit.issues.removeLabel({
owner,
repo: name,
issue_number: prNumber,
name: labelName,
});
}
}
}
}

run().catch(error => {
console.error(error);
process.exit(1);
});
97 changes: 58 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,63 @@
name: Build

on:
push:
branches:
- "*"
paths-ignore:
- ".gitignore"
pull_request:
branches:
- "*"
paths-ignore:
- ".gitignore"
workflow_dispatch:
push:
branches:
- "*"
paths-ignore:
- ".gitignore"
pull_request:
branches:
- "*"
paths-ignore:
- ".gitignore"
workflow_dispatch:
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
name: "Build and test"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Setup gradle
uses: gradle/gradle-build-action@v2
- name: Build with Gradle
run: ./gradlew build -x test --stacktrace
- uses: actions/upload-artifact@v3
name: Upload development build
with:
name: "Development Build"
path: build/libs/*.jar
- name: Test with Gradle
run: ./gradlew test
- uses: actions/upload-artifact@v3
name: "Upload test report"
if: ${{ !cancelled() }}
with:
name: "Test Results"
path: build/reports/tests/test/
build:
runs-on: ubuntu-latest
name: "Build and test"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Setup gradle
uses: gradle/gradle-build-action@v2
- name: Build with Gradle
run: ./gradlew assemble -x test --stacktrace
- uses: actions/upload-artifact@v3
name: Upload development build
with:
name: "Development Build"
path: versions/1.8.9/build/libs/*.jar
- name: Test with Gradle
run: ./gradlew test
- uses: actions/upload-artifact@v3
name: "Upload test report"
if: ${{ !cancelled() }}
with:
name: "Test Results"
path: versions/1.8.9/build/reports/tests/test/
preprocess:
runs-on: ubuntu-latest
name: "Build multi version"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Setup gradle
uses: gradle/gradle-build-action@v2
- name: Enable preprocessor
run: |
mkdir -p .gradle
echo skyhanni.multi-version=preprocess-only > .gradle/private.properties
- name: Build with Gradle
run: ./gradlew build --stacktrace
29 changes: 29 additions & 0 deletions .github/workflows/check_dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Check PR Dependencies

on:
pull_request_target:
types: [ opened, edited ]
push:
branches:
- beta

jobs:
check-dependencies:
runs-on: ubuntu-latest
steps:
- name: Check out the repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install dependencies
run: npm install @octokit/rest node-fetch

- name: Run dependency check script
run: node .github/scripts/checkDependencies.mjs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_CONTEXT: ${{ toJson(github) }}
6 changes: 3 additions & 3 deletions .github/workflows/generate-constants.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
name: "Generate regexes"
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: temurin
cache: gradle
- name: Setup gradle
Expand All @@ -33,7 +33,7 @@ jobs:
name: Upload generated repo regexes
with:
name: Repo Regexes
path: build/regexes/constants.json
path: versions/1.8.9/build/regexes/constants.json
publish-regexes:
runs-on: ubuntu-latest
needs: regexes
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ gradle.properties

.devauth/*
!.devauth/config.toml
.kotlin
1 change: 1 addition & 0 deletions .idea/dictionaries/default_user.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2694845

Please sign in to comment.