Skip to content

Commit 7bef86e

Browse files
committed
Fix #97 packaging doc and improve tags/branches to use
-- Bump brace-expansion in the npm_and_yarn group across 1 directory Bumps the npm_and_yarn group with 1 update in the / directory: [brace-expansion](https://github.com/juliangruber/brace-expansion). Updates `brace-expansion` from 2.0.1 to 2.0.2 - [Release notes](https://github.com/juliangruber/brace-expansion/releases) - [Commits](juliangruber/brace-expansion@v2.0.1...v2.0.2) --- updated-dependencies: - dependency-name: brace-expansion dependency-version: 2.0.2 dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] <support@github.com>
1 parent a1e4abf commit 7bef86e

12 files changed

Lines changed: 125 additions & 57 deletions

CONTRIBUTING.md renamed to .github/CONTRIBUTING.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# How to contribute
22
You're not a dev ? just submit an issue (bug, improvements, questions).
3+
* you could also fork, feature branch, then submit a pull request.
34

45
## HowTo setup
56

6-
* Install NodeJs and pnpm
7+
* Install Node.js and pnpm
78
* Clone
89
* Install deps
910
* setup your test environment (cf. [initenv.template.sh](./env/initenv.template.sh))
@@ -23,10 +24,8 @@ cp ./env/initenv.template.sh ./env/initenv.dontpush.sh
2324

2425
````bash
2526
. ./env/initenv.dontpush.sh
26-
pnpm run day
27-
pnpm run debugDay
28-
# or on windows : pnpm run debugDayWin
29-
pnpm run showResults
27+
pnpm day
28+
pnpm showResults
3029
# check other targets in package.json
3130
pnpm run
3231
````
@@ -36,23 +35,41 @@ pnpm run
3635
````bash
3736
. ./env/initenv.dontpush.sh
3837
# run all tests
39-
pnpm run test
38+
pnpm test
4039
# run all tests with code coverage
41-
pnpm run ci-test
40+
pnpm ci-test
4241
# run a single test file
43-
tst=1_sinon_based pnpm run tst
42+
tst=1_sinon_cloud_umami pnpm tst
4443
````
4544

4645

47-
* you could also fork, feature branch, then submit a pull request.
46+
## HowTo locally test GitHub action
47+
48+
* To run GitHub action workflow locally, cf [TESTING_ACTION](./TESTING_ACTION.md)
49+
50+
4851

49-
## HowTo package
52+
## HowTo reproduce package
53+
54+
Packaging is defined in `.github/scripts/package.sh`
5055
````bash
5156
pnpm install -g @vercel/ncc
5257
ncc build index.js
5358
# package result under dist/
5459
````
5560

61+
## HowTo publish a new umami-server compatible branch ?
62+
63+
- check that `package.json::orphanBranch` do match current umami server version compatibility of current source
64+
- create a version using patch/minor/major
65+
- create and push a `to-package` branch on the version you want to publish
66+
- this will trigger a `.github/workflows/main_ci_and_package_action.yml` workflow (internally with `MUST_BE_PACKAGED=true`)
67+
1) a dist package is created and pushed onto an orphan branch (`package.json::orphanBranch`)
68+
2) a new tag is (re-created and) pushed with `last-<orphanBranch>` as name to understand source code reference
69+
70+
For example the `umami-server-2.17.0` dist orphan branch used `last-umami-server-2.17.0` as source reference tag for the last packaging.
71+
72+
5673
## HowTo release using Gren
5774

5875
```bash

.github/TESTING_ACTION.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Testing the Action
2+
3+
This document describes how to test the action both locally and through GitHub.
4+
5+
## Local Testing
6+
7+
To test the action locally, you'll need:
8+
9+
- [Act](https://github.com/nektos/act) - A tool for running GitHub Actions locally
10+
- Docker installed on your machine
11+
12+
### Installation
13+
14+
- Install Act following the instructions at https://github.com/nektos/act#installation
15+
16+
- Setup workflow secrets : the tested workflow will rely on ([act vars](https://nektosact.com/usage/index.html#vars))
17+
18+
```bash
19+
cp env/.env.template env/.env.dontpush.act
20+
# edit env/.env.dontpush.act
21+
```
22+
23+
### Running Tests
24+
25+
- From the root of the repository, run:
26+
```bash
27+
# show workflow events
28+
act -l
29+
# or `gh act -l` if act is installed as gh client extension
30+
# run an event for a given workflow
31+
act -W '.github/workflows/00_pnpm_audit.yml' schedule
32+
gh act --secret-file env/.env.dontpush.act -W '.github/workflows/cron_daily_umami_report.yml' schedule
33+
```
34+
35+
This will execute the integration test workflow locally using Act.
36+
37+
## Notes
38+
39+
- The local tests using Act might behave slightly differently from GitHub Actions due to environment differences
40+
- Make sure you have enough disk space for Docker images when testing locally
41+
- The integration tests require Docker to be running locally

.github/workflows/00_pnpm_audit.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@ jobs:
2121
node-version: [20.x]
2222

2323
steps:
24-
- name: SETUP - Checkout
25-
uses: actions/checkout@v4
24+
- name: Checkout code
25+
uses: actions/checkout@v5
2626

2727
# https://github.com/pnpm/action-setup
28-
- name: SETUP - Install pnpm
28+
- name: Setup pnpm
2929
uses: pnpm/action-setup@v4
3030
with:
31+
# version from package.json
3132
run_install: false
3233

33-
- name: SETUP - Install Node.js ${{ matrix.node-version }}
34-
uses: actions/setup-node@v4
34+
- name: Setup Node.js ${{ matrix.node-version }}
35+
uses: actions/setup-node@v5
3536
with:
3637
node-version: ${{ matrix.node-version }}
3738
cache: 'pnpm'
38-
cache-dependency-path: pnpm-lock.yaml
3939

4040
- name: SETUP - Install dependencies
4141
run: |

.github/workflows/main_ci_and_package_action.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
# Triggers the workflow on push or pull request events but only for the prod branch
1010
push:
1111
branches:
12-
- stable
12+
- to-package
1313
- main
1414
pull_request:
1515
paths:
@@ -23,27 +23,27 @@ jobs:
2323
UMAMI_USER: ${{secrets.UMAMI_USERNAME}}
2424
UMAMI_PASSWORD: ${{secrets.UMAMI_PASSWORD}}
2525
UMAMI_SITE_DOMAIN: ${{secrets.UMAMI_SITE_DOMAIN}}
26-
MUST_BE_PACKAGED: ${{ github.ref == 'refs/heads/stable' || github.ref == 'refs/heads/main' }}
26+
MUST_BE_PACKAGED: ${{ github.ref == 'refs/heads/to-package' }}
2727
strategy:
2828
matrix:
2929
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
3030
node-version: [20.x]
3131
steps:
32-
- name: SETUP - Checkout
33-
uses: actions/checkout@v4
32+
- name: Checkout code
33+
uses: actions/checkout@v5
3434

3535
# https://github.com/pnpm/action-setup
36-
- name: SETUP - Install pnpm
36+
- name: Setup pnpm
3737
uses: pnpm/action-setup@v4
3838
with:
39+
# version from package.json
3940
run_install: false
4041

41-
- name: SETUP - Install Node.js ${{ matrix.node-version }}
42-
uses: actions/setup-node@v4
42+
- name: Setup Node.js ${{ matrix.node-version }}
43+
uses: actions/setup-node@v5
4344
with:
4445
node-version: ${{ matrix.node-version }}
4546
cache: 'pnpm'
46-
cache-dependency-path: pnpm-lock.yaml
4747

4848
- name: SETUP - Install dependencies
4949
run: |
@@ -99,9 +99,14 @@ jobs:
9999
# nb: jq extracts from package.json using 'orphanBranch' as key
100100
# warn: dont target 'main' as orphan branch
101101

102-
- name: PACKAGE - BUILD - autonomous package Action with deps in dist/
102+
- name: PACKAGE - BUILD - autonomous package Action with deps in dist/ and update last tag
103103
if: env.MUST_BE_PACKAGED == 'true'
104-
run: ./.github/scripts/package.sh
104+
run: |
105+
./.github/scripts/package.sh
106+
git tag -d "last-${ORPHAN_BRANCH}" || true
107+
git push origin ":refs/tags/last-${ORPHAN_BRANCH}" || true
108+
git tag "last-${ORPHAN_BRANCH}"
109+
git push origin "last-${ORPHAN_BRANCH}"
105110
106111
- name: DEPLOY package - push dist/ on target orphan branch ${{ env.ORPHAN_BRANCH }}
107112
uses: peaceiris/actions-gh-pages@v4

.github/workflows/pnpm_major.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@ jobs:
1414
node-version: [20.x]
1515

1616
steps:
17-
- name: SETUP - Checkout
18-
uses: actions/checkout@v4
19-
with:
20-
token: ${{ secrets.GH_ACTIONS_TOKEN }}
17+
- name: Checkout code
18+
uses: actions/checkout@v5
2119

2220
# https://github.com/pnpm/action-setup
23-
- name: SETUP - Install pnpm
21+
- name: Setup pnpm
2422
uses: pnpm/action-setup@v4
2523
with:
24+
# version from package.json
2625
run_install: false
2726

28-
- name: SETUP - Install Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v4
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v5
3029
with:
3130
node-version: ${{ matrix.node-version }}
3231
cache: 'pnpm'
33-
cache-dependency-path: pnpm-lock.yaml
3432

3533
- name: pnpm major
3634
run: |

.github/workflows/pnpm_minor.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@ jobs:
1414
node-version: [20.x]
1515

1616
steps:
17-
- name: SETUP - Checkout
18-
uses: actions/checkout@v4
19-
with:
20-
token: ${{ secrets.GH_ACTIONS_TOKEN }}
17+
- name: Checkout code
18+
uses: actions/checkout@v5
2119

2220
# https://github.com/pnpm/action-setup
23-
- name: SETUP - Install pnpm
21+
- name: Setup pnpm
2422
uses: pnpm/action-setup@v4
2523
with:
24+
# version from package.json
2625
run_install: false
2726

28-
- name: SETUP - Install Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v4
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v5
3029
with:
3130
node-version: ${{ matrix.node-version }}
3231
cache: 'pnpm'
33-
cache-dependency-path: pnpm-lock.yaml
3432

3533
- name: pnpm minor
3634
run: |

.github/workflows/pnpm_patch.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,21 @@ jobs:
1414
node-version: [20.x]
1515

1616
steps:
17-
- name: SETUP - Checkout
18-
uses: actions/checkout@v4
19-
with:
20-
token: ${{ secrets.GH_ACTIONS_TOKEN }}
17+
- name: Checkout code
18+
uses: actions/checkout@v5
2119

2220
# https://github.com/pnpm/action-setup
23-
- name: SETUP - Install pnpm
21+
- name: Setup pnpm
2422
uses: pnpm/action-setup@v4
2523
with:
24+
# version from package.json
2625
run_install: false
2726

28-
- name: SETUP - Install Node.js ${{ matrix.node-version }}
29-
uses: actions/setup-node@v4
27+
- name: Setup Node.js ${{ matrix.node-version }}
28+
uses: actions/setup-node@v5
3029
with:
3130
node-version: ${{ matrix.node-version }}
3231
cache: 'pnpm'
33-
cache-dependency-path: pnpm-lock.yaml
3432

3533
- name: pnpm patch
3634
run: |

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,13 @@ cf. working sample: cf. [(full) daily yml](.github/workflows/cron_daily_umami_re
8686

8787
**TIP**: if your umami server version is not compatible with current GithubActions, you could change
8888
`umami-server-2.17.0` keyword by one of
89-
the [current repository tags](https://github.com/boly38/action-umami-report/tags) with `umami-server-x.y` format.
89+
the [current repository branches](https://github.com/boly38/action-umami-report/branches) with `umami-server-x.y.z` format.
9090

9191
# See also
9292

93+
## Contribute
94+
- cf [CONTRIBUTING.md](./.github/CONTRIBUTING.md)
95+
9396
## Umami
9497

9598
Umami server : [API](https://umami.is/docs/api) - [source](https://github.com/umami-software/umami)

env/.env.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## gh act --secret-file env/.env.dontpush.act -W '.github/workflows/cron_daily_umami_report.yml' schedule
2+
UMAMI_SERVER=https://umami.replace-me.exemple.com
3+
UMAMI_USERNAME=admin
4+
UMAMI_PASSWORD=12333321
5+
UMAMI_SITE_DOMAIN=*first*
6+
UMAMI_TO_DISCORD_WEBHOOK_URL=

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
console.log("==> Running bundled version", __filename);
12
import UmamiReport from "./lib/umamiReport.js";
23

34
UmamiReport.githubActionReport()

0 commit comments

Comments
 (0)