Skip to content

Commit

Permalink
A few minor adjustments in scripts and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Apr 25, 2024
1 parent 7b091e0 commit a70ab1f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ Here are a few useul information for you:
proposed changes are going to be accepted by posting your ideas in
the [Feature Requests](https://github.com/ddnexus/pagy/discussions/categories/feature-requests) discussion area
2. For adding translations of locale dictionary files please follow
the [locales readme instructions here.](https://github.com/ddnexus/pagy/blob/master/gem/locales/README.md).
the [locales readme instructions here](https://github.com/ddnexus/pagy/blob/master/gem/locales/README.md).
3. **Development**
- Please base your PR against the `master` branch (creating your own branch out of it)
- Please create your own branch out of `master` and use it for you development and PR
- Ensure you are basing your PR on the `master` branch and keep rebasing it on `master` when it changes
- You can have a decent development environment already setup by just using one of the apps in
the [Pagy Playground](https://ddnexus.github.io/pagy/playground) and/or
with the [Pagy::Console](https://ddnexus.github.io/pagy/docs/api/console/) directly from the repo
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pagy-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ jobs:
config: baseUrl=http://0.0.0.0:8080,video=false
start: ${{ github.workspace }}/gem/bin/pagy ${{ matrix.app }} -p 8080
wait-on: http://0.0.0.0:8080
wait-on-timeout: 120
spec: cypress/e2e/${{ matrix.app }}.cy.ts
2 changes: 1 addition & 1 deletion README.md

Large diffs are not rendered by default.

30 changes: 21 additions & 9 deletions e2e/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@

# E2E Test Environment

Pagy provides quite a few helpers that render the pagination elements for different js-frameworks on the client side. They are tested with the [Pagy Playground](https://ddnexus.github.io/pagy/playground/) apps and [Cypress](https://www.cypress.io).
Pagy provides quite a few helpers that render the pagination elements for different js-frameworks on the client side. They are
tested with the [Pagy Playground](https://ddnexus.github.io/pagy/playground/) apps and [Cypress](https://www.cypress.io).

If you you need to run the E2E tests, here are two different ways to run them.

## 1. Github Actions

Just create a PR and all the ruby and e2e tests will run on GitHub. Usually this option is fine for simple PRs that pass the ruby tests.
Just create a PR and all the ruby and e2e tests will run on GitHub. Usually this option is fine for simple PRs that pass the ruby
tests.

**Notice**: This option is not enabled by default in Github for new contributors, however after you create a PR it will get enabled ASAP.
**Notice**: This option is not enabled by default in Github for new contributors, however after you create a PR it will get
enabled ASAP.

## 2. Run E2E Tests On Your System

[Install Cypress](https://docs.cypress.io/guides/getting-started/installing-cypress) and then:
Run `npm -i` or (`pnpm -i` if it is installed).

You can sequentially run all the e2e tests with:

```shell
<local-pagy-dir>/e2e $ APP=demo npm run test
# or run the test interactively
<local-pagy-dir>/e2e $ APP=demo npm run test-open
<local-pagy-dir>/e2e $ npm run test-all
```

Notice: you can test also other `APP` from the playground.
or limit the e2e test to a specific APP:

```shell
<local-pagy-dir>/e2e $ APP=demo PORT=8080 npm run test
```

You can also run the e2e test interactively (on one APP/file at the time):

```shell
<local-pagy-dir>/e2e $ APP=demo PORT=8080 npm run test-open
```
1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"scripts": {
"lint-fix": "eslint --fix cypress --ext .ts",
"test": "start-test \"bundle exec pagy $APP -p $PORT\" http://0.0.0.0:$PORT \"cypress run --config baseUrl=http://0.0.0.0:$PORT --spec cypress/e2e/$APP.cy.ts\"",
"test-all": "for app in repro rails calendar demo; do APP=$app PORT=8080 npm run test; done",
"test-open": "start-test \"bundle exec pagy $APP -p $PORT\" http://0.0.0.0:$PORT \"cypress open\""
}
}
2 changes: 1 addition & 1 deletion scripts/update_top100.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'net/http'

URL_FMT = 'https://api.github.com/repos/ddnexus/pagy/contributors?page=%s'
IMG_WIDTH = '60'
IMG_WIDTH = '40'
MAX_COUNT = 100
START_TAG = '<!-- top100 start -->'
END_TAG = '<!-- top100 end -->'
Expand Down
56 changes: 28 additions & 28 deletions scripts/version-bump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ set -e

# Set the root path
dir="$(dirname -- "$0")"
ROOT="$(cd -P -- "$(dirname -- "$dir")" && printf '%s\n' "$(pwd -P)")"
cd $ROOT
root="$(cd -P -- "$(dirname -- "$dir")" && printf '%s\n' "$(pwd -P)")"
cd $root

# Prompt for the new version
old_vers=$(ruby -Igem/lib -rpagy -e 'puts Pagy::VERSION')
Expand All @@ -31,40 +31,40 @@ function bump(){
sed -i "0,/$esc_old_vers/{s/$esc_old_vers/$esc_new_vers/}" "$1"
}

bump "$ROOT/retype.yml"
bump "$ROOT/.github/ISSUE_TEMPLATE/Code.yml"
bump "$ROOT/.github/latest_release_body.md"
bump "$ROOT/gem/apps/calendar.ru"
bump "$ROOT/gem/apps/demo.ru"
bump "$ROOT/gem/apps/rails.ru"
bump "$ROOT/gem/apps/repro.ru"
bump "$ROOT/gem/bin/pagy"
bump "$ROOT/gem/config/pagy.rb"
bump "$ROOT/gem/lib/pagy.rb"
bump "$ROOT/gem/pagy.gemspec"
bump "$ROOT/src/pagy.ts"
bump "$root/retype.yml"
bump "$root/.github/ISSUE_TEMPLATE/Code.yml"
bump "$root/.github/latest_release_body.md"
bump "$root/gem/apps/calendar.ru"
bump "$root/gem/apps/demo.ru"
bump "$root/gem/apps/rails.ru"
bump "$root/gem/apps/repro.ru"
bump "$root/gem/bin/pagy"
bump "$root/gem/config/pagy.rb"
bump "$root/gem/lib/pagy.rb"
bump "$root/gem/pagy.gemspec"
bump "$root/src/pagy.ts"

# Bumps docs example
esc_old_minor_vers=${esc_old_vers%\\*}
esc_new_minor_vers=${esc_new_vers%\\*}
sed -i "0,/$esc_old_minor_vers/{s/$esc_old_minor_vers/$esc_new_minor_vers/}" "$ROOT/quick-start.md"
sed -i "0,/$esc_old_minor_vers/{s/$esc_old_minor_vers/$esc_new_minor_vers/}" "$root/quick-start.md"

cd "$ROOT/src"
cd "$root/src"
pnpm run build
cd "$ROOT"
cd "$root"

# Set TMPLOG to the commit messages that have changes in the "gem" root path
TMPLOG=$(mktemp)
# Set tmplog to the commit messages that have changes in the "gem" root path
tmplog=$(mktemp)
# Iterate through the new commits
for commit in $(git rev-list "$old_vers"..HEAD)
do
if [[ -n $(git show --pretty="format:" --name-only --relative=gem $commit) ]]
then
git show --no-patch --format="- %s" $commit >> "$TMPLOG"
git show --no-patch --format="- %s" $commit >> "$tmplog"
body=$(git show --no-patch --format="%b" $commit)
if [[ -n "$body" ]]
then
sed 's/^/\ \ /' <<<"$body" >> "$TMPLOG"
sed 's/^/\ \ /' <<<"$body" >> "$tmplog"
fi
fi
done
Expand All @@ -73,22 +73,22 @@ done
# which is triggered by the :rubygem_release task (push tag)
lead='^<!-- changes start -->$'
tail='^<!-- changes end -->$'
sed -i "/$lead/,/$tail/{ /$lead/{p; r $TMPLOG
}; /$tail/p; d }" "$ROOT/.github/latest_release_body.md"
sed -i "/$lead/,/$tail/{ /$lead/{p; r $tmplog
}; /$tail/p; d }" "$root/.github/latest_release_body.md"

# Update CHANGELOG
changelog=$(cat <(echo -e "<hr>\n\n## Version $new_vers\n") "$TMPLOG")
CHANGELOG="$ROOT/CHANGELOG.md"
awk -v l="$changelog" '{sub(/<hr>/, l); print}' "$CHANGELOG" > "$TMPLOG"
mv "$TMPLOG" "$CHANGELOG"
changelog=$(cat <(echo -e "<hr>\n\n## Version $new_vers\n") "$tmplog")
changelog_path="$root/CHANGELOG.md"
awk -v l="$changelog" '{sub(/<hr>/, l); print}' "$changelog_path" > "$tmplog"
mv "$tmplog" "$changelog_path"

# Run test to check the consistency across files
bundle exec ruby -Itest test/pagy_test.rb --name "/pagy::Version match(#|::)/"

# Optional update of top 100
read -rp 'Do you want to update the "Top 100 contributors"? (y/n)> ' input
if [[ $input = y ]] || [[ $input = Y ]]; then
bundle exec "$ROOT/scripts/update_top100.rb"
bundle exec "$root/scripts/update_top100.rb"
fi

# Optional commit
Expand Down

0 comments on commit a70ab1f

Please sign in to comment.