-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/phifogg/ioBroker.reposito…
- Loading branch information
Showing
15 changed files
with
1,352 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Check archived repostories | ||
|
||
on: | ||
schedule: | ||
# * is a special character in YAML, so you have to quote this string | ||
# every sunday at 3:33 | ||
- cron: '33 3 * * 0' | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: npm i | ||
- run: npm run checkArchived | ||
env: | ||
OWN_GITHUB_TOKEN: ${{ secrets.OWN_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Check npm access | ||
|
||
on: | ||
schedule: | ||
# * is a special character in YAML, so you have to quote this string | ||
# daily at 2:2 | ||
- cron: '22 2 * * *' | ||
|
||
jobs: | ||
check-npms: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: npm i | ||
- run: npm run checkNpm | ||
env: | ||
OWN_GITHUB_TOKEN: ${{ secrets.OWN_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Automatically merge Dependabot PRs when version comparison is within the range | ||
# that is configured in .github/auto-merge.yml | ||
|
||
name: Auto-Merge Dependabot PRs | ||
|
||
on: | ||
# WARNING: This needs to be run in the PR base, DO NOT build untrusted code in this action | ||
# details under https://github.blog/changelog/2021-02-19-github-actions-workflows-triggered-by-dependabot-prs-will-run-with-read-only-permissions/ | ||
pull_request_target: | ||
|
||
jobs: | ||
auto-merge: | ||
if: github.actor == 'dependabot[bot]' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check if PR should be auto-merged | ||
uses: ahmadnassri/action-dependabot-auto-merge@v2 | ||
with: | ||
# In order to use this, you need to go to https://github.com/settings/tokens and | ||
# create a Personal Access Token with the permission "public_repo". | ||
# Enter this token in your repository settings under "Secrets" and name it AUTO_MERGE_TOKEN | ||
github-token: ${{ secrets.AUTO_MERGE_TOKEN }} | ||
# By default, squash and merge, so Github chooses nice commit messages | ||
command: squash and merge |
8 changes: 4 additions & 4 deletions
8
.github/workflows/stable.yml → .github/workflows/readyForStable.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow will triage pull requests and apply a label based on the | ||
# paths that are modified in the pull request. | ||
|
||
name: Set labels | ||
|
||
# | ||
# WARNING: | ||
# ** Do NOT run untrusted code when using pull_request_target ** | ||
# pull_request_target is needed as pull_request does not provide secrets and so no | ||
# labeling of PR is possible. | ||
# | ||
on: | ||
pull_request_target: | ||
types: [opened, edited, ready_for_review, reopened, labeled, unlabeled] | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
jobs: | ||
setLabels: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
- run: npm i | ||
- run: npm run setLabels | ||
env: | ||
OWN_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
'use strict'; | ||
|
||
/* | ||
* | ||
* This script scans all adapters listed at latest and stable repository and varifies that | ||
* - all adapters listed at stabel repository are also listed at latest repository | ||
* - github adapter repositories are accessible | ||
* - github adapter repositories are not archived | ||
* | ||
* If any of those checks fails an issue is created at ioBroker.repositories requesting a fix | ||
* | ||
* Note: | ||
* Running this script locally requires environmant variable OWN_GITHUB_TOKEN to be set to avoid hitting rate limits | ||
* | ||
*/ | ||
|
||
const { | ||
getGithub, | ||
getUrl, | ||
createIssue | ||
} = require('./common'); | ||
|
||
async function getLatestRepo() { | ||
return await getUrl('http://repo.iobroker.live/sources-dist-latest.json'); | ||
} | ||
|
||
async function getStableRepo() { | ||
return await getUrl('http://repo.iobroker.live/sources-dist.json'); | ||
} | ||
|
||
async function getStats() { | ||
return await getUrl('https://www.iobroker.net/data/statistics.json'); | ||
} | ||
|
||
async function checkRepos(latest, stable, stats) { | ||
const result = []; | ||
let count; | ||
let idx; | ||
|
||
count = Object.keys(stable).length; | ||
idx=0; | ||
console.log (''); | ||
console.log ('processing STABLE repository'); | ||
for (const adapter in stable) { | ||
idx = idx + 1; | ||
if (adapter.startsWith('_')) { | ||
console.log (`SKIPPING ${adapter} (${idx}/${count})`); | ||
} else { | ||
const parts = stable[adapter].meta.split('/'); | ||
const owner = parts[3]; | ||
console.log (`checking ${adapter} (${idx}/${count})`); | ||
if (!latest[adapter]) { | ||
console.log(` *** ${adapter} only in stable repository`); | ||
const item = { | ||
adapter: adapter, | ||
owner: owner, | ||
installs: stats.adapters[adapter], | ||
stable_only: true, | ||
}; | ||
console.log (` *** ${adapter} only at stable repository (${stats.adapters[adapter]} installs)`); | ||
result.push(item); | ||
} | ||
} | ||
} | ||
|
||
count = Object.keys(latest).length; | ||
idx = 0; | ||
console.log (''); | ||
console.log ('processing LATEST repository'); | ||
for (const adapter in latest) { | ||
idx = idx + 1; | ||
if (adapter.startsWith('_')) { | ||
console.log (`SKIPPING ${adapter} (${idx}/${count})`); | ||
} else { | ||
const parts = latest[adapter].meta.split('/'); | ||
const owner = parts[3]; | ||
console.log (`checking ${adapter} (${idx}/${count}) - ${owner}/ioBroker.${adapter}`); | ||
|
||
try { | ||
const json = await getGithub(`https://api.github.com/repos/${owner}/ioBroker.${adapter}`); | ||
if (json.archived) { | ||
const item = { | ||
adapter: adapter, | ||
owner: owner, | ||
installs: stats.adapters[adapter], | ||
archived: true, | ||
}; | ||
console.log (` *** ${adapter} is archived (${stats.adapters[adapter]} installs)`); | ||
result.push(item); | ||
} | ||
} catch (e) { | ||
console.log (` *** error retrieving infos for ${adapter}`); | ||
console.log (` *** ${e}`); | ||
const item = { | ||
adapter: adapter, | ||
owner: owner, | ||
installs: stats.adapters[adapter], | ||
error: true, | ||
e: e, | ||
}; | ||
result.push(item); | ||
} | ||
} | ||
}; | ||
return result; | ||
} | ||
|
||
async function generateIssue(adapter, stableFile) { | ||
let issues; | ||
issues = await getGithub(`https://api.github.com/repos/ioBroker/ioBroker.repositories/issues`); | ||
|
||
const title = `[CHECK] Adapter ${adapter.adapter} needs verification`; | ||
issues = issues.filter(i => i.state === 'open' && i.title.includes(title)); | ||
if (!issues.length) { | ||
let body = `# Adapter ${adapter.adapter} needs verification:\n\n`; | ||
if ( adapter.stable_only) { | ||
body += `Adapter is listed at stable repository only\n`; | ||
}; | ||
if ( adapter.archived) { | ||
body += `Repository ${adapter.owner}/ioBroker.${adapter.adapter} is archived\n`; | ||
}; | ||
if ( adapter.error) { | ||
body += `Retrieving data from repository ${adapter.owner}/ioBroker.${adapter.adapter} failed\n`; | ||
body += `${e}\n`; | ||
}; | ||
body += '\n'; | ||
body += `Adapter ${adapter.adapter} is currently installed ${adapter.installs} times\n`; | ||
|
||
body += '\n'; | ||
if ( adapter.stable_only) { | ||
body *= `- [ ] add adapter to latest repository if adapter repository is valid\n`; | ||
}; | ||
if ( adapter.archived) { | ||
body += `- [ ] verify that repository https://github.com/${adapter.owner}/ioBroker.${adapter.adapter} is really archived\n`; | ||
body += `- [ ] check if adapter has been migrated but links are not yet updated at repository\n`; | ||
body += ` fix links at repository if this is causing the problem\n`; | ||
body += `- [ ] decide if adapter should (and can) be moved to community-adapters (current usage ${adapter.installs} installs)\n`; | ||
body += `- [ ] move adapter to iobroker-community-adapters or \n`; | ||
body += ` remove adapter from repositories\n`; | ||
}; | ||
if ( adapter.error) { | ||
body += `- [ ] check repository ${adapter.owner}\ioBroker.${adapter.adapter}\n`; | ||
body += `- [ ] remove adapter from repositories if adapter repository invalid\n`; | ||
}; | ||
|
||
console.log(`\n`); | ||
console.log(`CREATE ISSUE for ioBroker.${adapter.adapter}: ${title}\n`); | ||
console.log(`${body}`); | ||
|
||
try { | ||
await createIssue('ioBroker', 'ioBroker.repositories', {title, body}); | ||
} catch (e) { | ||
console.log(`error: Cannot create issue for adapter ${adapter.adapter}:`); | ||
console.log(` ${e}`); | ||
}; | ||
} else { | ||
console.log(`ISSUE for ioBroker.${adapter.adapter} already exists`); | ||
} | ||
} | ||
|
||
|
||
async function doIt() { | ||
const latest = await getLatestRepo(); | ||
const stable = await getStableRepo(); | ||
const stats = await getStats(); | ||
const result = await checkRepos(latest, stable, stats); | ||
|
||
console.log (`The following adapters should be checked:`); | ||
for (const adapter of result) { | ||
console.log (` ${adapter.owner}/ioBroker.${adapter.adapter}`); | ||
} | ||
for (const adapter of result) { | ||
await generateIssue(adapter); | ||
} | ||
} | ||
|
||
doIt() | ||
.then(result => console.log('done')) | ||
.catch(e => console.error(e)); |
Oops, something went wrong.