From e8de79673809c8205928b7fe9191f71d0cb5656b Mon Sep 17 00:00:00 2001 From: Daniel N <2color@users.noreply.github.com> Date: Mon, 18 Sep 2023 12:21:02 +0200 Subject: [PATCH] ci: fix github workflows --- .github/workflows/data.yml | 33 ----------------------------- .github/workflows/pull_requests.yml | 26 ----------------------- dangerfile.js | 27 +++-------------------- scripts/remove-broken-links.js | 30 -------------------------- scripts/utils.js | 28 ------------------------ 5 files changed, 3 insertions(+), 141 deletions(-) delete mode 100644 .github/workflows/data.yml delete mode 100644 scripts/remove-broken-links.js delete mode 100644 scripts/utils.js diff --git a/.github/workflows/data.yml b/.github/workflows/data.yml deleted file mode 100644 index 3c25221..0000000 --- a/.github/workflows/data.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: auto build data - -on: - push: - branches: - - master - paths: - - data/** - -jobs: - build: - runs-on: ubuntu-latest - if: "!contains(github.event.head_commit.message, '[skip ci]') && github.repository == 'ipfs/awesome-ipfs'" - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 13 - - name: build - run: | - npm --version - node --version - npm ci - npm run lint - npm run build - - name: Commit files - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -m "Rebuild" -a - - name: Push changes - if: success() - run: git push diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index c7722b5..808fe7b 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -7,27 +7,8 @@ on: branches: [ master, main ] jobs: - # Run linting and tests - build-and-lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v1 - with: - node-version: 13 - - uses: ipfs/aegir/actions/cache-node-modules@master - with: - directories: | - README.md - build: | - npm run build:readme - cache_name: readme - # aegir/actions/cache-node-modules runs build. We don't need to run it again. - - run: npm run lint - run-danger: runs-on: ubuntu-latest - needs: build-and-lint if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Checkout @@ -40,13 +21,6 @@ jobs: uses: ruby/setup-ruby@v1 with: ruby-version: 3.1.2 - - uses: ipfs/aegir/actions/cache-node-modules@master - with: - directories: | - README.md - build: | - npm run build:readme - cache_name: readme - name: Install and run awesome_bot # It's okay for awesome_bot to fail (for maintainers only). Danger will post a comment on the PR (for maintainers only) if it fails. run: | diff --git a/dangerfile.js b/dangerfile.js index 3088c55..4fdad09 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -2,34 +2,13 @@ const { danger, markdown, fail, warn, message } = require('danger') const awesomeBotResults = require('./ab-results-README.md-markdown-table.json') const githubMetadata = danger.git.fileMatch('.github/**') -const yamlData = danger.git.fileMatch('data/**') -const scripts = danger.git.fileMatch('scripts/**') -const src = danger.git.fileMatch('src/**') const readme = danger.git.fileMatch('README.md') -if (readme.edited) { - fail('Please do not edit the README directly. It is generated from the data in the data/ directory.') +if (readme.edited && awesomeBotResults.error) { + fail(awesomeBotResults.title) + markdown(awesomeBotResults.message) } if (githubMetadata.edited) { message('Changes were made within the .github folder.') } - -if (yamlData.edited) { - message('YAML data files were edited.') - /** - * Only display awesomeBot results if the data yaml used to generate the readme have been modified. - */ - if (awesomeBotResults.error) { - fail(awesomeBotResults.title) - markdown(awesomeBotResults.message) - } -} - -if (scripts.edited) { - warn('Changes were made to the scripts folder.') -} - -if (src.edited) { - warn('Changes were made to the src folder.') -} diff --git a/scripts/remove-broken-links.js b/scripts/remove-broken-links.js deleted file mode 100644 index 1be90c0..0000000 --- a/scripts/remove-broken-links.js +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This file assumes that awesome_bot has already been ran. - */ -const markdownTable = require('../ab-results-README.md-markdown-table.json') -const fs = require('fs').promises -const { join } = require('path') - -const dir = join(__dirname, '../data') - -if (markdownTable.error) { - const brokenLinks = require('../ab-results-README.md-filtered.json').map((resultsData) => resultsData.link); - (async () => { - const files = (await fs.readdir(dir)).map(file => join(dir, file)) - - for await (const filePath of files) { - let fileContents = await fs.readFile(filePath, 'utf8') - brokenLinks.forEach((brokenLink) => { - console.log('Searching for "' + brokenLink + '" in ' + filePath) - const regex = new RegExp(brokenLink, 'g') - if (fileContents.match(regex)) { - fileContents = fileContents.replace(regex, '') - console.log('Removed "' + brokenLink + '" from ' + filePath) - } - }) - await fs.writeFile(filePath, fileContents, 'utf8') - } - })() -} else { - console.log('No errors reported by awesome_bot.') -} diff --git a/scripts/utils.js b/scripts/utils.js deleted file mode 100644 index 3573363..0000000 --- a/scripts/utils.js +++ /dev/null @@ -1,28 +0,0 @@ -const sort = (a, b) => { - if (a < b) return -1 - if (a > b) return 1 - return 0 -} - -const sortInv = (a, b) => -sort(a, b) - -const sortAbc = (a, b) => { - a = a.toLowerCase() - b = b.toLowerCase() - return sort(a, b) -} - -const slugify = (text) => text.toString() - .toLowerCase() - .replace(/\s+/g, '-') - .replace(/[^\w-]+/g, '') - .replace(/--+/g, '-') - .replace(/^-+/, '') - .replace(/-+$/, '') - -module.exports = { - sort, - sortInv, - sortAbc, - slugify -}