Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.
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
8 changes: 7 additions & 1 deletion scripts/get-repos/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import {Octokit} from '@octokit/rest'
import { Command } from 'commander/esm.mjs';

const LANGUAGES = ["JavaScript", "Go"]
const program = new Command();
program.option('-l, --languages [lang...]', 'languages (e.g. JavaScript, Go)', ['JavaScript', 'Go'])
program.parse(process.argv);
const opts = program.opts();

const LANGUAGES = opts.languages;
const ORGS = ["ipfs", "ipfs-shipyard", "ipld", "libp2p", "multiformats"]

const options = {}
Expand Down
16 changes: 15 additions & 1 deletion scripts/get-repos/package-lock.json

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

3 changes: 2 additions & 1 deletion scripts/get-repos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"author": "",
"license": "MIT",
"dependencies": {
"@octokit/rest": "^18.5.2"
"@octokit/rest": "^18.5.2",
"commander": "^8.0.0"
}
}
63 changes: 63 additions & 0 deletions scripts/health.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

to_status() {
if [[ $1 == 0 ]]; then
printf "✅"
return
fi
printf "❌"
}

check_go_mod_tidy() {
if [[ ! -f go.mod || ! -f go.sum ]]; then
echo 1
return
fi
cp go.mod go.mod.orig
cp go.sum go.sum.orig
go mod tidy &> /dev/null
diff go.mod go.mod.orig > /dev/null
if [[ $? != 0 ]]; then
echo 1
return
fi
diff go.sum go.sum.orig > /dev/null
echo $?
Copy link
Member

Choose a reason for hiding this comment

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

why echo? We could just do what we do for the other commands (capture the return status)

}

check_go_fmt() {
out=$(gofmt -l . | xargs)
if [[ -z "$out" ]]; then
echo 0
return
fi
echo 1
}

for repo in $(node get-repos/index.js -l Go | jq -r '.[]'); do
tmp=$(mktemp -d)
pushd $tmp > /dev/null
git clone -q https://github.com/$repo .
Copy link
Member

Choose a reason for hiding this comment

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

so... it would be nice if there were a way to tell this to clone from local repos... E.g., from a gopath.

Maybe just make the https://github.com part configurable?

if [[ ! -f .github/workflows/go-check.yml ]]; then # if the workflows aren't deployed yet
numcommits=$(git rev-list --count --since="Oct 1 2020" --all --no-merges)
pr=$(git branch -r --no-merged | grep -c web3-bot/sync)
if [[ $pr == 0 ]]; then # if there's no PR to add the workflows
gomodtidy=$(check_go_mod_tidy)
gofmt=$(check_go_fmt)
go test -failfast ./... &> /dev/null
gotest=$?
go test -failfast -race ./... &> /dev/null
gotestrace=$?
go vet ./... &> /dev/null
govet=$?
staticcheck ./... &> /dev/null
staticcheck=$?
echo "$repo $numcommits false $(to_status $gomodtidy) $(to_status $gofmt) $(to_status $gotest) $(to_status $gotestrace) $(to_status $govet) $(to_status $staticcheck)"
else
echo "$repo $numcommits true"
fi
fi
popd > /dev/null
Copy link
Member

Choose a reason for hiding this comment

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

I'd honestly just run this all in a subshell unless we need it to be in the main shell. I.e., replace the push/pop with

(
...
)

rm -rf $tmp
done