mirror of
https://github.com/status-im/sourcecred.git
synced 2025-01-16 23:51:31 +00:00
88f736d180
The scores are lightly processed from their internal representation. Example usage: ``` $ yarn backend; $ node bin/sourcecred.js load sourcecred/sourcecred $ node bin/sourcecred.js scores sourcecred/sourcecred > scores.json ``` The data structure is as follows: ```js export type NodeOutput = {| +id: string, +totalCred: number, +intervalCred: $ReadOnlyArray<number>, |}; export type ScoreOutput = Compatible<{| +users: $ReadOnlyArray<NodeOutput>, +intervals: $ReadOnlyArray<Interval>, |}>; ``` Test plan: I added sharness tests at `sharness/test_cli_scores.t`. In the past, we've used javascript tests for CLI commands. However, those are pretty time-consuming to write, and are less robust than simply running the command from bash. Check the snapshot for a sense of what the new data format looks like. Also, the snapshot updater now updates this snapshot too. Relevant for #1047. Thanks to @Beanow for feedback on the output format and design. Thanks to @wchargin for help in code review.
42 lines
1.2 KiB
Bash
Executable File
42 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Automatically update all SourceCred snapshot data.
|
|
set -eu
|
|
|
|
toplevel="$(git -C "$(dirname "$0")" rev-parse --show-toplevel)"
|
|
cd "${toplevel}"
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
cleanup() {
|
|
rm -r "${tmpdir}"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
SOURCECRED_BIN="${tmpdir}/bin"
|
|
yarn run --silent backend --output-path "${SOURCECRED_BIN}"
|
|
export SOURCECRED_BIN # for Sharness and shell tests
|
|
export NODE_PATH="${toplevel}/node_modules${NODE_PATH:+:${NODE_PATH}}"
|
|
|
|
echo "Updating GitHub GraphQL Flow types"
|
|
cp .prettierrc.json "${SOURCECRED_BIN}/"
|
|
node "${SOURCECRED_BIN}/generateGithubGraphqlFlowTypes.js" \
|
|
>src/plugins/github/graphqlTypes.js
|
|
|
|
echo "Updating sharness/test_load_example_github.t"
|
|
(cd sharness; UPDATE_SNAPSHOT=1 ./test_load_example_github.t -l)
|
|
|
|
echo "Updating sharness/test_cli_scores.t"
|
|
(cd sharness; UPDATE_SNAPSHOT=1 ./test_cli_scores.t -l)
|
|
|
|
echo "Updating git/loadRepositoryTest.sh"
|
|
./src/plugins/git/loadRepositoryTest.sh -u --no-build
|
|
|
|
echo "Updating github/fetchGithubOrgTest.sh"
|
|
./src/plugins/github/fetchGithubOrgTest.sh -u --no-build
|
|
|
|
echo "Updating github/fetchGithubRepoTest.sh"
|
|
./src/plugins/github/fetchGithubRepoTest.sh -u --no-build
|
|
|
|
echo "Updating Jest snapshots"
|
|
yarn unit -u
|