Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

deploy JS unified CI script #274

Merged
merged 6 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/check-3rd-party.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ for line in `sed -ne 's/[[:space:]-]*uses:[[:space:]]*//p' $1 | sed -e 's/\s*#.*
# - .: local workflows
# "actions": workflows authored by GitHub
# "protocol": workflows published in the protocol org
if [[ $author == "." || $author == "actions" || $author == "protocol" ]]; then continue; fi
# "ipfs": workflows published in the ipfs org
if [[ $author == "." || $author == "actions" || $author == "protocol" || $author == "ipfs" ]]; then continue; fi
version=`echo $line | awk -F@ '{print $2}' | awk '{print $1}'`
if ! [[ "$version" =~ ^[a-f0-9]{40}$ ]]; then
status=1
echo "$FILE includes $line and doesn't use commit hash"
fi
done
done

exit $status
1 change: 1 addition & 0 deletions configs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ This directory contains config files used for workflow dispatch.
| name | description |
| --- | --- |
| go | repositories containing Go code |
| js | repositories containing JS code |
| testing | repositories used for testing unified CI workflows |

## Adding new repository to existing config file
Expand Down
14 changes: 14 additions & 0 deletions configs/js.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"defaults": {
"files": [
galargh marked this conversation as resolved.
Show resolved Hide resolved
".github/workflows/automerge.yml",
".github/workflows/js-test-and-release.yml"
]
},
"repositories": [
{ "target": "ipfs/js-blockstore-core" },
{ "target": "libp2p/js-libp2p-crypto" },
{ "target": "libp2p/js-libp2p-interfaces" },
{ "target": "libp2p/js-libp2p-tcp" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{ "target": "libp2p/js-libp2p-tcp" }
{ "target": "libp2p/js-libp2p-tcp" },
{ "target": "alanshaw/it-pipe" },
{ "target": "alanshaw/it-goodbye" }

vasco-santos/is-loopback-addr should also be in here but it's primary branch is called main and not master so I guess #262 needs merging first?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that these repos will need to grant permissions to the web3-bot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't have to wait for #262 because $default-branch string is already replaced in our templated with a name of the default branch. #262 only generalises the templating approach.

As for more repos, how about we start with the original 4 to make sure the setup works as expected first? @achingbrain Could you check if web3-bot is allowed to write to ipfs/js-blockstore-core#14? I don't have access to settings in that repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha, gotcha.

I've added web3-bot to blockstore-core and the stewards team, @alanshaw is doing his various it-* repos.

Happy to merge this without the extra repos - since the bot is gaining perms we can add them later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is someone monitoring the web3-bot inbox for repo invites? They have to be manually approved by web3-bot if you're not adding it to a repo from an org it's already a member of.

]
}
151 changes: 151 additions & 0 deletions templates/.github/workflows/js-test-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: test & maybe release
on:
push:
branches:
- $default-branch # with #262 - ${{{ github.default_branch }}}
pull_request:
branches:
- $default-branch # with #262 - ${{{ github.default_branch }}}

jobs:

check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This action doesn't have to live in the aegir repo - when we're happy with the workflow it could be moved here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also make a separate repo for it if we want to put it on the marketplace - similarly to what we did here https://github.com/protocol/cache-go-action. For now though, we can leave it in ipfs/aegir.

- run: npm run --if-present lint
- run: npm run --if-present dep-check

test-node:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
node: [16]
fail-fast: true
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:node
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
galargh marked this conversation as resolved.
Show resolved Hide resolved
with:
directory: ./.nyc_output
flags: node

test-chrome:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome
galargh marked this conversation as resolved.
Show resolved Hide resolved
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: chrome

test-chrome-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:chrome-webworker
galargh marked this conversation as resolved.
Show resolved Hide resolved
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: chrome-webworker

test-firefox:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npm run --if-present test:firefox
galargh marked this conversation as resolved.
Show resolved Hide resolved
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: firefox

test-firefox-webworker:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: firefox-webworker

test-electron-main:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-main
galargh marked this conversation as resolved.
Show resolved Hide resolved
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: electron-main

test-electron-renderer:
needs: check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- run: npx xvfb-maybe npm run --if-present test:electron-renderer
galargh marked this conversation as resolved.
Show resolved Hide resolved
- uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0
with:
directory: ./.nyc_output
flags: electron-renderer

release:
needs: [test-node, test-chrome, test-chrome-webworker, test-firefox, test-firefox-webworker, test-electron-main, test-electron-renderer]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/$default-branch' # with #262 - 'refs/heads/${{{ github.default_branch }}}'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-node@v2
with:
node-version: lts/*
- uses: ipfs/aegir/actions/cache-node-modules@master
- uses: ipfs/aegir/actions/docker-login@master
achingbrain marked this conversation as resolved.
Show resolved Hide resolved
with:
docker-token: ${{ secrets.DOCKER_USERNAME }}
docker-username: ${{ secrets.DOCKER_USERNAME }}
- run: npm run --if-present release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}