Skip to content

Commit

Permalink
Update create-slug.sh (#233)
Browse files Browse the repository at this point in the history
* Update create-slug.sh

Update script to pull from cardano-cli and cardano-api repositories.

* expand to include new cardano-cli and cardano-api repos

* remove set -x

* remove set -x
  • Loading branch information
CarlosLopezDeLara authored Sep 12, 2023
1 parent ce28dee commit ef44bf2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 30 deletions.
9 changes: 3 additions & 6 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ The following scripts are included in this repository:

To use these scripts, follow the instructions below:

1. Run the `download-prs.sh` script by executing the following command:
1. Run the `download-prs.sh` script providing a "repository" and a "start-date" (YYYY-MM-DD) as arguments. The script will download all PRs created after the start date. For example:

```bash
./scripts/download-prs.sh input-output-hk/cardano-node
./scripts/download-prs.sh input-output-hk/cardano-node 2023-06-30
```

This script will download the PRs that were merged between two specified dates and . Please note that the end date is exclusive.

2. Execute the `distribute-merged-prs.sh` script using the following command:

```bash
Expand All @@ -48,7 +46,7 @@ Execute the create-slug.sh script with the following command:
```bash
./create-slug.sh <author> <date> <end_date>
```
This script will create a markdown file named blog/<date>-node-cli-api.md, authored by "<author>", with sections for updates from "<date>" to "<end_date>". It automatically runs the PR summary scripts as defined above so you can cherry pick the PRs as necessary.
This script will create a markdown file named blog/<date>-node-cli-api.md, authored by "<author>", with sections for updates from "<date>" to "<end_date>". It automatically runs the PR summary scripts as defined above so you can cherry pick the PRs as necessary.


## Additional Information
Expand All @@ -57,4 +55,3 @@ This script will create a markdown file named blog/<date>-node-cli-api.md, autho
- Manual intervention is required between the distribution and summarization stages. This step allows for detailed edits, such as removing irrelevant PRs, from the summary. The detail section of the summary includes a file list, making it easier to assess the relevance of each PR to the component.

For an example of the output produced by each script, refer to the [example commit](https://github.com/input-output-hk/cardano-node/pull/5137/commits) on the official GitHub repository.

22 changes: 14 additions & 8 deletions scripts/create-slug.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

# Author's name
AUTHOR=$1
# Date in the format YYYY-MM-DD
Expand Down Expand Up @@ -33,23 +35,27 @@ hide_table_of_contents: false
## High level summary
### docs
### CI & project maintenance
### Developer experience
### cardano-cli
### cardano-api
### cardano-node
### cardano-testnet
### docs
### CI & project maintenance
EOF

source scripts/download-prs.sh input-output-hk/cardano-node
source scripts/download-prs.sh input-output-hk/cardano-node $DATE
source scripts/download-prs.sh input-output-hk/cardano-cli $DATE
source scripts/download-prs.sh input-output-hk/cardano-api $DATE

source scripts/distribute-merged-prs.sh input-output-hk/cardano-node current $DATE $END_DATE
source scripts/distribute-merged-prs.sh input-output-hk/cardano-cli current $DATE $END_DATE
source scripts/distribute-merged-prs.sh input-output-hk/cardano-api current $DATE $END_DATE

source scripts/summarise-merged-prs.sh input-output-hk/cardano-node current
source scripts/summarise-merged-prs.sh input-output-hk/cardano-node current
source scripts/summarise-merged-prs.sh input-output-hk/cardano-cli current
source scripts/summarise-merged-prs.sh input-output-hk/cardano-api current
24 changes: 12 additions & 12 deletions scripts/distribute-merged-prs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -euo pipefail

(yq --version | grep https://github.com/mikefarah/yq/ > /dev/null) || {
echo "Please install yq from https://github.com/mikefarah/yq/" > /dev/stderr
exit 1
Expand Down Expand Up @@ -34,19 +36,17 @@ mkdir -p "$work_subdir/detail"
cat "$download_file" | yq -o json | jq -r "$(
cat <<EOF
map
( select
( true
and (.baseRefName = "master")
and (.mergedAt >= "$start_date")
and (.mergedAt < "$end_date")
( select(
(.baseRefName == "master" and .mergedAt >= "$start_date" and .mergedAt <= "$end_date") or
(.baseRefName == "main" and .mergedAt >= "$start_date" and .mergedAt <= "$end_date")
)
| { "title": .title
, "author": .author.name
, "url": .url
, "number": .number
, "mergedAt": .mergedAt
, "include": "undecided"
, "files": .files | map(.path)
| { "title": .title
, "author": .author.name
, "url": .url
, "number": .number
, "mergedAt": .mergedAt
, "include": "undecided"
, "files": .files | map(.path)
}
)
EOF
Expand Down
11 changes: 7 additions & 4 deletions scripts/download-prs.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/bash

set -euo pipefail

(yq --version | grep https://github.com/mikefarah/yq/ > /dev/null) || {
echo "Please install yq from https://github.com/mikefarah/yq/" > /dev/stderr
exit 1
}

if [ "$#" -ne 1 ]; then
if [ "$#" -ne 2 ]; then
echo "Usage: $0 repository" >&2
echo "Example: $0 input-output-hk/cardano-node" >&2
exit 1
Expand All @@ -18,15 +20,16 @@ else
fi

repository="$1"
date="$2"

out_dir="gen/$repository"

mkdir -p "$out_dir"

temp_json_file="$(mktemp).json"

# Requires the default repository to be set in gh
max_pr_number="$(gh pr list --state all --limit 1 --json number | jq '.[0].number // 1000')"
# Find a reasonable number for -L
max_pr_number="$(gh pr list --repo "$repository" --state all --search "created:>=$date" -L 1000 --json number | jq length)"

echo "Downloading up to $max_pr_number PRs"

Expand All @@ -36,4 +39,4 @@ gh pr list --repo "$repository" \
--json number,title,author,createdAt,closedAt,files,mergedAt,baseRefName,url,body \
> "$temp_json_file"

cat "$temp_json_file" | yq -P > "$out_dir/download.yaml"
cat "$temp_json_file" | yq -P > "$out_dir/download.yaml"

0 comments on commit ef44bf2

Please sign in to comment.