Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ So when `flashlight: true`, the action writes a `.env.local` for the run, built
2. the values imposed by the Flashlight container: `PRESTAFLOW_FO_URL`,
`PRESTAFLOW_BO_URL` (`<fo>admin-dev/`) and `PRESTAFLOW_PS_VERSION`;
3. your own dotenv file, copied as is: `.env.local` if it exists, otherwise `.env`;
4. the Flashlight back-office credentials: `[email protected]`,
`PRESTAFLOW_BO_PASSWD=prestashop`.
4. the Flashlight credentials: the back office (`[email protected]`,
`PRESTAFLOW_BO_PASSWD=prestashop`) and the demo customer of the PrestaShop fixtures
(`[email protected]`, `PRESTAFLOW_FO_PASSWD=123456789`).

If your repository already has a `.env.local`, it is merged and put back at the end of
the run; otherwise the generated file is removed.
Expand All @@ -78,9 +79,32 @@ the run; otherwise the generated file is removed.
ps-version: '8.1.7'
```

If your committed `.env` sets `PRESTAFLOW_BO_EMAIL` / `PRESTAFLOW_BO_PASSWD` for your
local shop, they win over the Flashlight defaults: remove them from `.env`, or set the
Flashlight ones with `env:` on the step.
If your committed `.env` sets `PRESTAFLOW_BO_EMAIL` / `PRESTAFLOW_BO_PASSWD` (or the
`FO_` pair) for your local shop, they win over the Flashlight defaults: remove them from
`.env`, or set the Flashlight ones with `env:` on the step.

### prestaflow/php-library 1.9.0

Since 1.9.0 the library no longer signs in with the demo accounts when
`PRESTAFLOW_FO_EMAIL` / `PRESTAFLOW_BO_EMAIL` are unset: the steps that need an
account are skipped. With Flashlight the action provides both accounts (above).
Without Flashlight, set them for the shop you test, for instance from secrets:

```yaml
- uses: PrestaFlow/github-action@v2
env:
PRESTAFLOW_FO_EMAIL: ${{ secrets.SHOP_CUSTOMER_EMAIL }}
PRESTAFLOW_FO_PASSWD: ${{ secrets.SHOP_CUSTOMER_PASSWORD }}
PRESTAFLOW_BO_EMAIL: ${{ secrets.SHOP_ADMIN_EMAIL }}
PRESTAFLOW_BO_PASSWD: ${{ secrets.SHOP_ADMIN_PASSWORD }}
with:
token: ${{ secrets.PRESTAFLOW_TOKEN }}
```

The settings added in 1.9.0 go through `env:` like any other `PRESTAFLOW_*` variable:
`PRESTAFLOW_BO_LOCALE`, `PRESTAFLOW_SHOP_ID`, `PRESTAFLOW_VISUAL_BASELINE`,
`PRESTAFLOW_ONLY_TEST`, `PRESTAFLOW_BROWSER_WS` / `PRESTAFLOW_BROWSER_WS_TOKEN`…
See the [configuration reference](https://prestaflow.io/docs/library/1/getting-started/configuration).

## PR comment

Expand Down
18 changes: 18 additions & 0 deletions __tests__/flashlight/dotenv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import {
renderFlashlightDotenv,
writeFlashlightDotenv,
FLASHLIGHT_BO_EMAIL,
FLASHLIGHT_FO_EMAIL,
FLASHLIGHT_FO_PASSWD,
FLASHLIGHT_BO_PASSWD,
} from '../../src/flashlight/dotenv';

Expand Down Expand Up @@ -69,6 +71,22 @@ describe('renderFlashlightDotenv', () => {
expect(v.PRESTAFLOW_PS_VERSION).toBe(`'8.1.7'`);
expect(v.PRESTAFLOW_BO_EMAIL).toBe(`'${FLASHLIGHT_BO_EMAIL}'`);
expect(v.PRESTAFLOW_BO_PASSWD).toBe(`'${FLASHLIGHT_BO_PASSWD}'`);
expect(v.PRESTAFLOW_FO_EMAIL).toBe(`'${FLASHLIGHT_FO_EMAIL}'`);
expect(v.PRESTAFLOW_FO_PASSWD).toBe(`'${FLASHLIGHT_FO_PASSWD}'`);
});

it('user file and step env override the Flashlight demo customer', () => {
const fromFile = lastValues(renderFlashlightDotenv({
...base, userContent: '[email protected]\nPRESTAFLOW_FO_PASSWD=secret', processEnv: {},
}));
expect(fromFile.PRESTAFLOW_FO_EMAIL).toBe('[email protected]');
expect(fromFile.PRESTAFLOW_FO_PASSWD).toBe('secret');

const fromEnv = lastValues(renderFlashlightDotenv({
...base, userContent: null, processEnv: { PRESTAFLOW_FO_EMAIL: 'ci@x', PRESTAFLOW_FO_PASSWD: 'pw' },
}));
expect(fromEnv.PRESTAFLOW_FO_EMAIL).toBe(`'ci@x'`);
expect(fromEnv.PRESTAFLOW_FO_PASSWD).toBe(`'pw'`);
});

it('user file overrides Flashlight default credentials but not forced values', () => {
Expand Down
16 changes: 13 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -126310,7 +126310,7 @@ var __importStar = (this && this.__importStar) || (function () {
};
})();
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.FLASHLIGHT_ADMIN_DIR = exports.FLASHLIGHT_BO_PASSWD = exports.FLASHLIGHT_BO_EMAIL = void 0;
exports.FLASHLIGHT_ADMIN_DIR = exports.FLASHLIGHT_FO_PASSWD = exports.FLASHLIGHT_FO_EMAIL = exports.FLASHLIGHT_BO_PASSWD = exports.FLASHLIGHT_BO_EMAIL = void 0;
exports.encodeDotenvValue = encodeDotenvValue;
exports.pickPrestaflowEnv = pickPrestaflowEnv;
exports.flashlightDefaults = flashlightDefaults;
Expand All @@ -126324,6 +126324,11 @@ const path = __importStar(__nccwpck_require__(16928));
// (see https://github.com/PrestaShop/prestashop-flashlight#readme).
exports.FLASHLIGHT_BO_EMAIL = '[email protected]';
exports.FLASHLIGHT_BO_PASSWD = 'prestashop';
// Demo customer of the PrestaShop fixtures the image installs. prestaflow/php-library
// 1.9.0 no longer falls back on a demo account when PRESTAFLOW_FO_EMAIL is unset:
// without these, every step that signs a customer in would be skipped.
exports.FLASHLIGHT_FO_EMAIL = '[email protected]';
exports.FLASHLIGHT_FO_PASSWD = '123456789';
// Flashlight renames the admin folder to this fixed name.
exports.FLASHLIGHT_ADMIN_DIR = 'admin-dev';
const KEY_RE = /^[A-Za-z_][A-Za-z0-9_.]*$/;
Expand Down Expand Up @@ -126362,7 +126367,12 @@ function block(title, vars) {
return [`# ${title}`, ...keys.map(k => `${k}=${encodeDotenvValue(vars[k])}`), ''];
}
function flashlightDefaults() {
return { PRESTAFLOW_BO_EMAIL: exports.FLASHLIGHT_BO_EMAIL, PRESTAFLOW_BO_PASSWD: exports.FLASHLIGHT_BO_PASSWD };
return {
PRESTAFLOW_BO_EMAIL: exports.FLASHLIGHT_BO_EMAIL,
PRESTAFLOW_BO_PASSWD: exports.FLASHLIGHT_BO_PASSWD,
PRESTAFLOW_FO_EMAIL: exports.FLASHLIGHT_FO_EMAIL,
PRESTAFLOW_FO_PASSWD: exports.FLASHLIGHT_FO_PASSWD,
};
}
function flashlightForced(foUrl, psVersion) {
return {
Expand All @@ -126385,7 +126395,7 @@ function renderFlashlightDotenv(p) {
'# Generated by PrestaFlow/github-action for the Flashlight run.',
'# Later assignments win. The original file is restored after the run.',
'',
...block('Flashlight default back-office credentials', flashlightDefaults()),
...block('Flashlight default credentials (back office and demo customer)', flashlightDefaults()),
];
if (p.userContent !== null) {
lines.push('# --- user dotenv file ---', p.userContent.replace(/\s*$/, ''), '# --- end of user dotenv file ---', '');
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/flashlight/dotenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import * as path from 'path';
// (see https://github.com/PrestaShop/prestashop-flashlight#readme).
export const FLASHLIGHT_BO_EMAIL = '[email protected]';
export const FLASHLIGHT_BO_PASSWD = 'prestashop';
// Demo customer of the PrestaShop fixtures the image installs. prestaflow/php-library
// 1.9.0 no longer falls back on a demo account when PRESTAFLOW_FO_EMAIL is unset:
// without these, every step that signs a customer in would be skipped.
export const FLASHLIGHT_FO_EMAIL = '[email protected]';
export const FLASHLIGHT_FO_PASSWD = '123456789';
// Flashlight renames the admin folder to this fixed name.
export const FLASHLIGHT_ADMIN_DIR = 'admin-dev';

Expand Down Expand Up @@ -55,7 +60,12 @@ export interface RenderParams {
}

export function flashlightDefaults(): Record<string, string> {
return { PRESTAFLOW_BO_EMAIL: FLASHLIGHT_BO_EMAIL, PRESTAFLOW_BO_PASSWD: FLASHLIGHT_BO_PASSWD };
return {
PRESTAFLOW_BO_EMAIL: FLASHLIGHT_BO_EMAIL,
PRESTAFLOW_BO_PASSWD: FLASHLIGHT_BO_PASSWD,
PRESTAFLOW_FO_EMAIL: FLASHLIGHT_FO_EMAIL,
PRESTAFLOW_FO_PASSWD: FLASHLIGHT_FO_PASSWD,
};
}

export function flashlightForced(foUrl: string, psVersion: string): Record<string, string> {
Expand All @@ -80,7 +90,7 @@ export function renderFlashlightDotenv(p: RenderParams): string {
'# Generated by PrestaFlow/github-action for the Flashlight run.',
'# Later assignments win. The original file is restored after the run.',
'',
...block('Flashlight default back-office credentials', flashlightDefaults()),
...block('Flashlight default credentials (back office and demo customer)', flashlightDefaults()),
];
if (p.userContent !== null) {
lines.push('# --- user dotenv file ---', p.userContent.replace(/\s*$/, ''), '# --- end of user dotenv file ---', '');
Expand Down
Loading