Skip to content

Commit bef5f5b

Browse files
authored
Merge branch 'trunk' into custom-dev-env-sync
2 parents eb14388 + 834ec18 commit bef5f5b

File tree

17 files changed

+121
-246
lines changed

17 files changed

+121
-246
lines changed

.github/workflows/ai-changelog.yml

Lines changed: 2 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -19,85 +19,7 @@ jobs:
1919
github.event.issue.pull_request &&
2020
github.event.comment.body == '/changelog'
2121
steps:
22-
- name: Acknowledge request
23-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
22+
- name: Generate changelog for PR
23+
uses: Automattic/vip-actions/ai-changelog-generator@a10bde8914496b7386d10fc5df9b4ffa2fd72ef1
2424
with:
25-
issue-number: ${{ github.event.issue.number }}
26-
reactions: 'eyes'
27-
comment-id: ${{ github.event.comment.id }}
28-
29-
- name: Verify OpenAI API Key is available
30-
run: |
31-
if [ -z "${OPENAI_API_KEY}" ]; then
32-
echo "OPENAI_API_KEY is not set."
33-
exit 1
34-
fi
35-
env:
36-
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
37-
38-
- name: Check if user has write access
39-
id: check_access
40-
uses: actions/github-script@v7.0.1
41-
with:
42-
script: |
43-
const { data: membership } = await github.rest.repos.getCollaboratorPermissionLevel({
44-
owner: context.repo.owner,
45-
repo: context.repo.repo,
46-
username: context.payload.comment.user.login
47-
});
48-
if (membership.permission !== 'write' && membership.permission !== 'admin' && membership.permission !== 'maintain') {
49-
core.setFailed(`User ${context.payload.comment.user.login} does not have write access.`);
50-
} else {
51-
core.setOutput("authorized", 'true');
52-
}
53-
54-
- name: Generate Changelog Entry
55-
if: steps.check_access.outputs.authorized == 'true'
56-
id: changelog
57-
uses: Automattic/vip-actions/ai-changelog@1ca5877971f93f05fceaa0efd119c40218c1da1e # trunk
58-
with:
59-
pr_number: ${{ github.event.issue.number }}
6025
openai_api_key: ${{ secrets.OPENAI_API_KEY }}
61-
62-
- name: Find Comment
63-
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
64-
if: steps.check_access.outputs.authorized == 'true'
65-
id: fc
66-
with:
67-
issue-number: ${{ github.event.issue.number }}
68-
comment-author: 'github-actions[bot]'
69-
body-includes: '## AI-Generated Changelog Entry'
70-
direction: last
71-
72-
- name: Post Changelog Comment
73-
if: >
74-
steps.check_access.outputs.authorized == 'true' &&
75-
steps.changelog.outputs.changelog_entry
76-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
77-
with:
78-
issue-number: ${{ github.event.issue.number }}
79-
body: |
80-
## AI-Generated Changelog Entry
81-
82-
${{ steps.changelog.outputs.changelog_entry }}
83-
84-
comment-id: ${{ steps.fc.outputs.comment-id }}
85-
edit-mode: replace
86-
87-
- name: Set status (success)
88-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
89-
if: success()
90-
with:
91-
issue-number: ${{ github.event.issue.number }}
92-
reactions: 'hooray'
93-
comment-id: ${{ github.event.comment.id }}
94-
reactions-edit-mode: replace
95-
96-
- name: Set status (failure)
97-
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
98-
if: failure()
99-
with:
100-
issue-number: ${{ github.event.issue.number }}
101-
reactions: '-1'
102-
comment-id: ${{ github.event.comment.id }}
103-
reactions-edit-mode: replace

__tests__/lib/analytics/clients/tracks.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
11
import nock from 'nock';
2-
import url from 'url';
32

43
import Tracks from '../../../../src/lib/analytics/clients/tracks';
54
import * as apiConfig from '../../../../src/lib/cli/apiConfig';
65

76
describe( 'lib/analytics/tracks', () => {
8-
const {
9-
protocol: endpointProtocol,
10-
host: endpointHost,
11-
path: endpointPath,
12-
} = url.parse( Tracks.ENDPOINT );
7+
const url = new URL( Tracks.ENDPOINT );
138

14-
const buildNock = () => {
15-
return nock( `${ endpointProtocol }//${ endpointHost }` ).post( endpointPath );
16-
};
9+
const buildNock = () => nock( url.origin ).post( url.pathname );
1710

1811
afterEach( nock.cleanAll );
1912

2013
describe( '.send()', () => {
21-
/**
22-
* Allow overriding of process variables per test
23-
* Adapted from https://stackoverflow.com/a/48042799
24-
*/
25-
const OLD_ENV = process.env;
26-
27-
beforeEach( () => {
28-
jest.resetModules();
29-
process.env = { ...OLD_ENV };
30-
} );
31-
32-
afterEach( () => {
33-
process.env = OLD_ENV;
34-
} );
35-
3614
it( 'should correctly construct remote request', () => {
3715
const tracksClient = new Tracks( 123, 'vip', '', {
3816
userAgent: 'vip-cli',

__tests__/lib/cli/config.js

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
import fs from 'node:fs';
2+
3+
import { loadConfigFile } from '../../../src/lib/cli/config';
4+
15
describe( 'utils/cli/config', () => {
2-
beforeEach( () => {
3-
jest.resetModules();
4-
jest.clearAllMocks();
6+
afterEach( () => {
7+
jest.restoreAllMocks();
58
} );
9+
610
it.each( [
711
{
812
description: 'should return development if config.local.json is present',
@@ -17,28 +21,26 @@ describe( 'utils/cli/config', () => {
1721
{
1822
description: 'should throw error if config.local.json and config.publish.json are missing',
1923
files: { local: false, publish: false },
20-
expected: Error,
24+
expected: null,
2125
},
2226
] )( '$description', ( { files, expected } ) => {
23-
// An array of files would've been nicer but it doesn't play well with jest.doMock
24-
if ( ! files.local ) {
25-
jest.doMock( '../../../config/config.local.json', () => {
26-
throw new Error();
27-
} );
28-
}
29-
if ( ! files.publish ) {
30-
jest.doMock( '../../../config/config.publish.json', () => {
27+
const origReadFileSync = fs.readFileSync;
28+
jest.spyOn( fs, 'readFileSync' ).mockImplementation( ( filePath, ...params ) => {
29+
if ( typeof filePath !== 'string' || ! filePath.includes( 'config.' ) ) {
30+
return origReadFileSync( filePath, ...params );
31+
}
32+
33+
if (
34+
( filePath.includes( 'config.local.json' ) && ! files.local ) ||
35+
( filePath.includes( 'config.publish.json' ) && ! files.publish )
36+
) {
3137
throw new Error();
32-
} );
33-
}
38+
}
39+
40+
return JSON.stringify( expected );
41+
} );
3442

35-
if ( ! files.local && ! files.publish ) {
36-
// eslint-disable-next-line jest/no-conditional-expect
37-
expect( () => require( '../../../src/lib/cli/config' ) ).toThrow( expected );
38-
} else {
39-
const config = require( '../../../src/lib/cli/config' );
40-
// eslint-disable-next-line jest/no-conditional-expect
41-
expect( config.default ).toMatchObject( expected );
42-
}
43+
const actual = loadConfigFile();
44+
expect( actual ).toStrictEqual( expected );
4345
} );
4446
} );

__tests__/lib/validations/is-multisite-domain-mapped.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
*/
44

55
import nock from 'nock';
6-
import url from 'url';
76

87
import { API_URL } from '../../../src/lib/api';
98
import {
@@ -80,10 +79,10 @@ describe( 'is-multisite-domain-mapped', () => {
8079

8180
describe( 'isMultisitePrimaryDomainMapped', () => {
8281
beforeEach( () => {
83-
const { protocol, host, path } = url.parse( API_URL );
82+
const url = new URL( API_URL );
8483

85-
nock( `${ protocol }//${ host }` )
86-
.post( path )
84+
nock( url.origin )
85+
.post( url.pathname )
8786
.reply( 200, {
8887
data: {
8988
app: {

npm-shrinkwrap.json

Lines changed: 18 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@automattic/vip",
3-
"version": "3.19.1-dev.0",
3+
"version": "3.19.2-dev.0",
44
"description": "The VIP Javascript library & CLI",
55
"main": "index.js",
66
"bin": {
@@ -164,15 +164,15 @@
164164
"ini": "5.0.0",
165165
"js-yaml": "^4.1.0",
166166
"jwt-decode": "4.0.0",
167-
"lando": "github:automattic/lando-cli#25136fb80684743276239e2ee155080f3056790c",
167+
"lando": "github:automattic/lando-cli#4cbdcf85ddd8b7ff53e912b9d9f1fced57ce39b7",
168168
"node-fetch": "^2.6.1",
169169
"node-stream-zip": "1.15.0",
170170
"open": "^10.0.0",
171171
"proxy-from-env": "^1.1.0",
172172
"semver": "7.7.2",
173173
"shelljs": "^0.10.0",
174174
"socket.io-client": "^4.5.3",
175-
"socket.io-stream": "npm:@wearemothership/socket.io-stream@^0.9.1",
175+
"socket.io-stream": "npm:@wwa/socket.io-stream@^0.10.0",
176176
"socks-proxy-agent": "^8.0.5",
177177
"ssh2": "1.16.0",
178178
"tar": "^7.4.0",

src/bin/vip-app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ command( { requiredArgs: 1, format: true } )
7070
await trackEvent( 'app_command_success' );
7171

7272
// Clone the read-only response object so we can modify it
73-
const clonedResponse = Object.assign( {}, res );
73+
const clonedResponse = { ...res };
7474

7575
clonedResponse.environments = clonedResponse.environments.map( env => {
76-
const clonedEnv = Object.assign( {}, env );
76+
const clonedEnv = { ...env };
7777

7878
clonedEnv.name = getEnvIdentifier( env );
7979

0 commit comments

Comments
 (0)