Skip to content

Add KotlinLeeds for kotlin, android #240

Add KotlinLeeds for kotlin, android

Add KotlinLeeds for kotlin, android #240

Workflow file for this run

name: PR Check
on:
pull_request:
types: [opened]
paths:
- 'conferences/*/*.json'
jobs:
check-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Check if PR is dev-related
id: check-dev-related
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
// High-confidence development-related keywords (score: +3)
const HIGH_CONFIDENCE_KEYWORDS = [
"frontend", "backend", "fullstack", "devops", "javascript", "typescript",
"react", "angular", "vue", "node.js", "nodejs", "python", "java",
"ruby", "golang", "rust", "scala", "kotlin", "swift", "php",
"dotnet", ".net", "c#", "cpp", "c++", "elixir", "haskell", "clojure",
"programming", "developer", "coding", "software development",
"web development", "mobile development", "app development",
"git", "github", "gitlab", "docker", "kubernetes", "microservices",
"api development", "rest api", "graphql", "database design",
"sql", "nosql", "mongodb", "postgresql", "redis", "ci/cd",
"test automation", "unit testing", "integration testing"
];
// Medium-confidence keywords (score: +2)
const MEDIUM_CONFIDENCE_KEYWORDS = [
"software", "programming", "developer", "engineering", "code",
"framework", "library", "open source", "opensource", "agile", "scrum",
"architecture", "infrastructure", "cloud computing", "serverless",
"container", "deployment", "version control", "debugging"
];
// Low-confidence keywords (score: +1) - only count if combined with others
const LOW_CONFIDENCE_KEYWORDS = [
"tech", "technology", "digital", "innovation", "platform",
"system", "network", "security", "performance", "automation"
];
// Exclusion keywords that indicate non-dev conferences (score: -5)
const EXCLUSION_KEYWORDS = [
"medicine", "medical", "health", "healthcare", "clinical", "pharmaceutical",
"biology", "biomedical", "stem cell", "vaccine", "immunology",
"climate", "environment", "energy", "renewable", "sustainability",
"finance", "banking", "accounting", "economics", "business management",
"marketing", "sales", "hr", "human resources", "education", "teaching",
"psychology", "sociology", "law", "legal", "agriculture", "farming",
"chemistry", "physics", "mathematics", "statistics", "research",
"academic", "scientific", "conference on", "symposium on", "workshop on",
"semiconductor", "optoelectronics", "photonics", "electronics", "electrical",
"hardware", "mechanical", "materials", "nanotechnology", "nanoscience",
"sensors", "signal processing", "robotics", "automation", "manufacturing",
"aerospace", "automotive", "telecommunications", "wireless", "circuits",
"embedded systems", "microelectronics", "bioengineering", "chemical engineering"
];
// Function to calculate dev-relatedness score
function calculateDevScore(conferenceName) {
const lowerName = conferenceName.toLowerCase();
let score = 0;
// Check for exclusion keywords first
for (const keyword of EXCLUSION_KEYWORDS) {
if (lowerName.includes(keyword.toLowerCase())) {
score -= 5;
}
}
// Check high confidence keywords
for (const keyword of HIGH_CONFIDENCE_KEYWORDS) {
if (lowerName.includes(keyword.toLowerCase())) {
score += 3;
}
}
// Check medium confidence keywords
for (const keyword of MEDIUM_CONFIDENCE_KEYWORDS) {
if (lowerName.includes(keyword.toLowerCase())) {
score += 2;
}
}
// Check low confidence keywords
for (const keyword of LOW_CONFIDENCE_KEYWORDS) {
if (lowerName.includes(keyword.toLowerCase())) {
score += 1;
}
}
return score;
}
// Function to check if a conference name is dev-related
function isDevRelated(conferenceName) {
const score = calculateDevScore(conferenceName);
// Require a minimum score of 3 to be considered dev-related
return score >= 3;
}
// Check if we're running in a real PR context or in a test environment
try {
// Make sure we have a valid PR number
if (!context.issue.number) {
console.log("No PR number found, assuming test environment.");
return 'test-mode';
}
// Get the list of files changed in the PR
const response = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
// Filter for conference JSON files
const conferenceFiles = response.data.filter(file =>
file.filename.match(/conferences\/.*\/.*\.json/));
console.log(`Found ${conferenceFiles.length} conference files in PR:`);
conferenceFiles.forEach(file => {
console.log(`- ${file.filename} (status: ${file.status})`);
});
if (conferenceFiles.length === 0) {
console.log("No conference files found in this PR");
return 'false';
} // For each conference file, check its content
for (const file of conferenceFiles) {
try {
console.log(`\n=== Processing file: ${file.filename} ===`);
// Get the diff for this specific file to see only what was added
const diffResponse = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
headers: {
accept: 'application/vnd.github.v3.diff'
}
});
// Parse the diff to extract only added lines for this file
const diffText = diffResponse.data;
const fileDiffs = diffText.split('diff --git');
let addedConferencesText = '';
for (const fileDiff of fileDiffs) {
if (fileDiff.includes(`a/${file.filename}`) && fileDiff.includes(`b/${file.filename}`)) {
// Found the diff for our file
const lines = fileDiff.split('\n');
for (const line of lines) {
if (line.startsWith('+') && !line.startsWith('+++')) {
// This is an added line
addedConferencesText += line.substring(1) + '\n';
}
}
break;
}
}
console.log(`Added content:\n${addedConferencesText}`);
// Extract conference names from added content using regex
const nameMatches = addedConferencesText.match(/"name":\s*"([^"]+)"/g);
if (!nameMatches) {
console.log(`No conference names found in added content for ${file.filename}`);
continue;
}
const addedConferenceNames = nameMatches.map(match => {
const nameMatch = match.match(/"name":\s*"([^"]+)"/);
return nameMatch ? nameMatch[1] : null;
}).filter(name => name !== null);
console.log(`Found ${addedConferenceNames.length} new conferences in ${file.filename}:`);
addedConferenceNames.forEach(name => console.log(`- ${name}`));
// Check each new conference
for (const conferenceName of addedConferenceNames) {
const score = calculateDevScore(conferenceName);
console.log(`Conference: "${conferenceName}" - Score: ${score} (NEWLY ADDED to ${file.filename})`);
if (isDevRelated(conferenceName)) {
console.log(`Found dev-related NEW conference: ${conferenceName} in file ${file.filename}`);
return 'true';
}
}
} catch (fileError) {
console.log(`Error accessing content of ${file.filename}: ${fileError.message}`);
continue;
}
}
// If we checked all files and found no dev-related conferences
return 'false';
} catch (error) {
console.log(`Error accessing PR details: ${error.message}`);
console.log("Assuming test environment. Workflow validation should pass.");
return 'test-mode';
}
- name: Add labels and notify
if: steps.check-dev-related.outputs.result != 'test-mode'
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const isDev = '${{ steps.check-dev-related.outputs.result }}' === 'true';
try {
// Add appropriate label
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [isDev ? 'dev-related' : 'non-dev-related']
});
// Add appropriate comment
if (isDev) {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '👨‍💻 A development-related conference has been detected!'
});
} else {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'This PR appears to be non-dev-related based on conference content analysis. It has been labeled as `non-dev-related`. If you believe this is an error, please let us know. Thank you!'
});
}
} catch (error) {
console.log(`Error in labeling or commenting: ${error.message}`);
}
- name: Test mode notification
if: steps.check-dev-related.outputs.result == 'test-mode'
run: |
echo "Running in test mode - skipping GitHub API interactions."
echo "The workflow syntax is valid and ready for real PR processing."