fix: mulit-page pagination calculation errors #247
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and Build | |
on: [push] | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-20.04 | |
outputs: | |
branch: ${{ steps.branchinfo.outputs.branch }} | |
steps: | |
- uses: nelonoel/branch-name@v1.0.1 | |
# - name: Update npm until we use next LTS | |
# run: sudo npm install -g npm@latest | |
- name: Store the branch name | |
id: branchinfo | |
run: echo "branch=${BRANCH_NAME}" >> $GITHUB_OUTPUT | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: "npm" | |
- name: ssh fix for npm install | |
uses: webfactory/ssh-agent@v0.4.1 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Install Dependencies | |
run: npm install | |
- name: Lint | |
run: npx eslint --max-warnings=0 . | |
- name: Unit Tests | |
run: npm run test:coverage | |
- name: E2E Tests | |
uses: cypress-io/github-action@v5 | |
with: | |
start: npm run start:coverage | |
# wait-on: "http://localhost:3000" | |
wait-on: 'http://[::1]:3000' | |
config-file: cypress.config.ci.ts | |
- name: Merge Coverage Reports | |
run: | | |
ls -l ./coverage | |
npm run merge-coverage | |
ls -l ./coverage/merged | |
ls -ld coverage/integration/lcov.info | |
ls -ld coverage/unit/lcov.info | |
# - name: Codacy Coverage | |
# uses: codacy/codacy-coverage-reporter-action@v1 | |
# with: | |
# project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} | |
# coverage-reports: coverage/integration/lcov.info,coverage/unit/lcov.info | |
- name: Coveralls Unit | |
uses: coverallsapp/github-action@master | |
with: | |
flag-name: "Unit" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: "./coverage/unit/lcov.info" | |
parallel: true | |
- name: Coveralls Integration | |
uses: coverallsapp/github-action@master | |
with: | |
flag-name: "E2E" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path-to-lcov: "./coverage/integration/lcov.info" | |
parallel: true | |
- name: Coveralls Finished | |
uses: coverallsapp/github-action@master | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
parallel-finished: true | |
- name: Check coveralls stuff | |
run: | | |
ls -ld ./coverage/unit/lcov.info | |
ls -ld ./coverage/integration/lcov.info | |
ls -la ./coverage | |
build: | |
name: Build | |
runs-on: ubuntu-20.04 | |
needs: test | |
if: ${{ needs.test.outputs.branch == 'main' }} | |
env: | |
CYPRESS_CACHE_FOLDER: cypress/cache | |
CYPRESS_SKIP_BINARY_INSTALL: yes | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: "npm" | |
- name: ssh fix for npm install | |
uses: webfactory/ssh-agent@v0.4.1 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Install Dependencies | |
run: npm install | |
- name: Get Current Version | |
id: currentVersion | |
run: | | |
version=`node -p "require('./package.json').version"` | |
echo "value=${version}" >> $GITHUB_OUTPUT | |
- name: Get Next Version | |
id: nextVersion | |
run: echo "value=$(npm run --silent release-version)" >> $GITHUB_OUTPUT | |
- run: echo "${{ steps.currentVersion.outputs.value }} vs ${{ steps.nextVersion.outputs.value }}" | |
- name: Should We Release? | |
id: shouldRelease | |
run: | | |
should=`[[ "${{ steps.nextVersion.outputs.value }}" != "" ]] && [[ "${{ steps.nextVersion.outputs.value }}" != "${{ steps.currentVersion.outputs.value }}" ]] && echo "yes" || echo "no"` | |
echo "value=${should}" >> $GITHUB_OUTPUT | |
- name: Update Copyright Year | |
if: steps.shouldRelease.outputs.value == 'yes' | |
run: | | |
npm run update-copyright-year | |
git status | |
git add src/pages/main/Footer.tsx | |
- name: Build | |
if: steps.shouldRelease.outputs.value == 'yes' | |
run: | | |
npm run build | |
tar -C ./dist -czvf ./release-${{ steps.nextVersion.outputs.value }}.tar.gz . | |
- name: Do Release Changes | |
if: steps.shouldRelease.outputs.value == 'yes' | |
# NOTE: Currently runs `standard-version --prerelease`. | |
# Update the release script in package.json to change | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "github-actions@github.com" | |
npm run release | |
- name: Commit Release | |
if: steps.shouldRelease.outputs.value == 'yes' | |
run: | | |
git status | |
git add . | |
git push origin | |
- name: Create Release | |
if: steps.shouldRelease.outputs.value == 'yes' | |
id: createRelease | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: release-${{ steps.nextVersion.outputs.value }}.tar.gz | |
tag: v${{ steps.nextVersion.outputs.value }} | |
name: Release v${{ steps.nextVersion.outputs.value }} | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish to Cloudflare Pages | |
if: steps.shouldRelease.outputs.value == 'yes' | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
apiToken: ${{ secrets.CF_API_PAGES_DEPLOY_TOKEN }} | |
accountId: ${{ secrets.CF_ACCOUNT_ID }} | |
command: pages publish --project-name=printables dist |