Skip to content

Commit dbe2303

Browse files
authored
Merge branch 'main' into pr/fix/schematics-fixes-and-theming-support
2 parents 3d8b8ba + 5402e45 commit dbe2303

21 files changed

+370
-50
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Get version
2+
description: Get version from package.json and check if pre-release
3+
4+
outputs:
5+
pre-release:
6+
description: Is prerelease version
7+
version:
8+
description: Current version
9+
10+
runs:
11+
using: node16
12+
main: ./index.js

.github/actions/get-version/index.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const semver = require('semver');
2+
const fs = require('fs');
3+
const core = require('@actions/core');
4+
const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
5+
const currentVersion = packageJson.version;
6+
7+
const run = async () => {
8+
const prerelease = !!semver.prerelease(currentVersion, undefined);
9+
10+
if (prerelease) {
11+
core.info(`Current version is a prerelease, skipping...`);
12+
} else {
13+
core.info(`Current version is a stable release, continuing...`);
14+
}
15+
16+
core.setOutput('pre-release', prerelease);
17+
core.setOutput('version', currentVersion);
18+
};
19+
20+
run();
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Fork of https://github.com/probablyup/wait-for-netlify-action
2+
name: 'Wait for Netlify Deployment'
3+
description: 'Waits for the current GitHub commit Netlify deploy to be ready. Useful in combination with tools like Lighthouse or Cypress.'
4+
5+
inputs:
6+
site_id:
7+
description: 'The Netlify site ID to test against, get this from the Netlify UI under site settings.'
8+
required: true
9+
max_timeout:
10+
description: 'The max time to wait after the deployment is ready for a valid HTTP status code.'
11+
required: false
12+
commit_sha:
13+
description: 'The commit SHA to wait for.'
14+
required: true
15+
16+
outputs:
17+
deploy_id:
18+
description: 'The Netlify deployment ID'
19+
url:
20+
description: 'The fully qualified deployment URL'
21+
22+
runs:
23+
using: node16
24+
main: ./index.js
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
const core = require('@actions/core');
2+
const axios = require('axios');
3+
4+
const READY_STATES = ['ready', 'current'];
5+
6+
function getNetlifyUrl(url) {
7+
return axios.get(url, {
8+
headers: {
9+
Authorization: `Bearer ${process.env.NETLIFY_TOKEN}`
10+
}
11+
});
12+
}
13+
14+
const waitForDeployCreation = (url, commitSha, MAX_TIMEOUT) => {
15+
const increment = 15;
16+
17+
return new Promise((resolve, reject) => {
18+
let elapsedTimeSeconds = 0;
19+
20+
const handle = setInterval(async () => {
21+
elapsedTimeSeconds += increment;
22+
23+
if (elapsedTimeSeconds >= MAX_TIMEOUT) {
24+
clearInterval(handle);
25+
return reject(`Timeout reached: Deployment was not created within ${MAX_TIMEOUT} seconds.`);
26+
}
27+
28+
const { data: netlifyDeployments } = await getNetlifyUrl(url);
29+
30+
if (!netlifyDeployments) {
31+
return reject(`Failed to get deployments for site`);
32+
}
33+
34+
const commitDeployment = netlifyDeployments.find((d) => d.commit_ref === commitSha);
35+
36+
if (commitDeployment) {
37+
clearInterval(handle);
38+
return resolve(commitDeployment);
39+
}
40+
41+
console.log(`Not yet created, waiting ${increment} more seconds...`);
42+
}, increment * 1000);
43+
});
44+
};
45+
46+
const waitForReadiness = (url, MAX_TIMEOUT) => {
47+
const increment = 30;
48+
49+
return new Promise((resolve, reject) => {
50+
let elapsedTimeSeconds = 0;
51+
let state;
52+
53+
const handle = setInterval(async () => {
54+
elapsedTimeSeconds += increment;
55+
56+
if (elapsedTimeSeconds >= MAX_TIMEOUT) {
57+
clearInterval(handle);
58+
return reject(
59+
`Timeout reached: Deployment was not ready within ${MAX_TIMEOUT} seconds. Last known deployment state: ${state}.`
60+
);
61+
}
62+
63+
const { data: deploy } = await getNetlifyUrl(url);
64+
65+
state = deploy.state;
66+
67+
if (READY_STATES.includes(state)) {
68+
clearInterval(handle);
69+
return resolve();
70+
}
71+
72+
console.log(`Not yet ready, waiting ${increment} more seconds...`);
73+
}, increment * 1000);
74+
});
75+
};
76+
77+
const waitForUrl = async (url, MAX_TIMEOUT) => {
78+
const iterations = MAX_TIMEOUT / 3;
79+
for (let i = 0; i < iterations; i++) {
80+
try {
81+
await axios.get(url);
82+
return;
83+
} catch (e) {
84+
console.log(`URL ${url} unavailable, retrying...`);
85+
await new Promise((r) => setTimeout(r, 3000));
86+
}
87+
}
88+
core.setFailed(`Timeout reached: Unable to connect to ${url}`);
89+
};
90+
91+
const run = async () => {
92+
try {
93+
const netlifyToken = process.env.NETLIFY_TOKEN;
94+
const commitSha = core.getInput('commit_sha');
95+
const MAX_CREATE_TIMEOUT = 60 * 5; // 5 min
96+
const MAX_WAIT_TIMEOUT = 60 * 15; // 15 min
97+
const MAX_READY_TIMEOUT = Number(core.getInput('max_timeout')) || 60;
98+
const siteId = core.getInput('site_id');
99+
100+
if (!netlifyToken) {
101+
core.setFailed('Please set NETLIFY_TOKEN env variable to your Netlify Personal Access Token secret');
102+
}
103+
if (!commitSha) {
104+
core.setFailed('Could not determine GitHub commit');
105+
}
106+
if (!siteId) {
107+
core.setFailed('Required field `site_id` was not provided');
108+
}
109+
110+
console.log(`Waiting for Netlify to create a deployment for git SHA ${commitSha}`);
111+
const commitDeployment = await waitForDeployCreation(
112+
`https://api.netlify.com/api/v1/sites/${siteId}/deploys`,
113+
commitSha,
114+
MAX_CREATE_TIMEOUT
115+
);
116+
117+
const url = `https://${commitDeployment.id}--${commitDeployment.name}.netlify.app`;
118+
119+
core.setOutput('deploy_id', commitDeployment.id);
120+
core.setOutput('url', url);
121+
122+
console.log(
123+
`Waiting for Netlify deployment ${commitDeployment.id} in site ${commitDeployment.name} to be ready`
124+
);
125+
await waitForReadiness(
126+
`https://api.netlify.com/api/v1/sites/${siteId}/deploys/${commitDeployment.id}`,
127+
MAX_WAIT_TIMEOUT
128+
);
129+
130+
console.log(`Waiting for a 200 from: ${url}`);
131+
await waitForUrl(url, MAX_READY_TIMEOUT);
132+
} catch (error) {
133+
core.setFailed(typeof error === 'string' ? error : error.message);
134+
}
135+
};
136+
137+
run();

.github/workflows/update-versions.yml

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ on:
77
- completed
88

99
jobs:
10-
check-version-type:
10+
prepare:
1111
runs-on: ubuntu-latest
1212
if: github.event.workflow_run.conclusion == 'success'
1313
outputs:
14-
pre-release: ${{ steps.check-pre-release.outputs.pre-release }}
14+
pre-release: ${{ steps.get-version.outputs.pre-release }}
15+
version: ${{ steps.get-version.outputs.version }}
16+
commit-sha: ${{ steps.get-last-commit.outputs.commit-sha }}
1517
steps:
1618
- name: Fetch from origin repo
1719
uses: actions/checkout@v3
@@ -23,21 +25,18 @@ jobs:
2325
- name: Setup Node.js and Cache
2426
uses: ./.github/actions/nodejs
2527

26-
- name: Check if pre release
27-
id: check-pre-release
28-
run: |
29-
PRE_RELEASE=$(echo "${{ github.event.workflow_run.head_commit.message }}" | grep -e "-rc." -c) || :
30-
if [ $PRE_RELEASE -eq 0 ]; then
31-
echo "Not a pre-release, continuing..."
32-
else
33-
echo "Pre-release detected, skipping..."
34-
fi
35-
echo "::set-output name=pre-release::$PRE_RELEASE"
28+
- name: Check if pre release & get version
29+
id: get-version
30+
uses: ./.github/actions/get-version
31+
32+
- name: Get last commit SHA
33+
id: get-last-commit
34+
run: echo "::set-output name=commit-sha::$(git rev-parse HEAD)"
3635

37-
update_versions:
36+
update-versions:
3837
runs-on: ubuntu-latest
39-
needs: check-version-type
40-
if: needs.check-version-type.outputs.pre-release == 0
38+
needs: prepare
39+
if: needs.prepare.outputs.pre-release == 'false'
4140
steps:
4241
- name: Fetch from origin repo
4342
uses: actions/checkout@v3
@@ -51,9 +50,10 @@ jobs:
5150

5251
- name: Wait for Netlify Deployment
5352
id: wait-for-deployment
54-
uses: probablyup/wait-for-netlify[email protected]
53+
uses: ./.github/actions/wait-for-netlify
5554
with:
5655
site_id: ${{ secrets.NETLIFY_SITE_ID }}
56+
commit_sha: ${{ needs.prepare.outputs.commit-sha }}
5757
env:
5858
NETLIFY_TOKEN: ${{ secrets.NETLIFY_TOKEN }}
5959

@@ -62,9 +62,14 @@ jobs:
6262
with:
6363
url: ${{ steps.wait-for-deployment.outputs.url }}
6464

65+
- uses: ./.github/actions/set-up-git
66+
name: Set up git user
67+
with:
68+
name: ${{ secrets.GH_NAME }}
69+
email: ${{ secrets.GH_EMAIL }}
70+
6571
- name: Commit Changes
6672
run: |
67-
VERSION=$(echo "${{ github.event.workflow_run.head_commit.message }}" | grep -E "v[0-9]+[^ ]+" -o)
6873
git add .
69-
git commit -m "chore(release): add $VERSION to versions.json [ci skip]" --no-verify
74+
git commit -m "chore(release): add v${{ needs.prepare.outputs.version }} to versions.json [ci skip]" --no-verify
7075
git push

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## [0.36.3-rc.23](https://github.com/SAP/fundamental-ngx/compare/v0.36.3-rc.22...v0.36.3-rc.23) (2022-11-04)
2+
3+
4+
### Bug Fixes
5+
6+
* **fn:** show selected option label in select ([#8828](https://github.com/SAP/fundamental-ngx/issues/8828)) ([1a1ea1a](https://github.com/SAP/fundamental-ngx/commit/1a1ea1a0c1e81d1b652e22b6036d895d368e5ae8))
7+
8+
9+
10+
## [0.36.3-rc.22](https://github.com/SAP/fundamental-ngx/compare/v0.36.3-rc.21...v0.36.3-rc.22) (2022-11-04)
11+
12+
13+
### Bug Fixes
14+
15+
* **docs:** update versions workflow ([#8825](https://github.com/SAP/fundamental-ngx/issues/8825)) ([c381d58](https://github.com/SAP/fundamental-ngx/commit/c381d58f4c9196b249332c66355fd70ab41001a3))
16+
17+
18+
119
## [0.36.3-rc.21](https://github.com/SAP/fundamental-ngx/compare/v0.36.3-rc.20...v0.36.3-rc.21) (2022-11-04)
220

321

libs/docs/fn/select/examples/select-example/select-editable-example-component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,12 @@ export class SelectEditableExampleComponent {
1616
'Tomato',
1717
'Strawberry'
1818
];
19+
20+
options2: { name: string; kCal: string }[] = [
21+
{ name: 'Apple', kCal: '49.05' },
22+
{ name: 'Apple', kCal: '50' },
23+
{ name: 'Kiwi', kCal: '36' },
24+
{ name: 'Tomato', kCal: '24' },
25+
{ name: 'Strawberry', kCal: '32' }
26+
];
1927
}
Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
<div style="width: 200px">
2-
<fn-select [editable]="true" placeholder="Select an option" label="Editable Selector" #selectEditableExample>
3-
<li fn-option *ngFor="let option of options" [value]="option">{{ option }}</li>
2+
<fn-select [editable]="true" placeholder="Select an option" label="Editable Selector" #selectEditableExample1>
3+
<li fn-option *ngFor="let option of options" [value]="option" [label]="option"></li>
44
</fn-select>
55
</div>
6+
7+
<p>
8+
<i>Editable Example selection: {{ selectEditableExample1.value }}</i>
9+
</p>
610
<br />
711

12+
<div style="width: 200px">
13+
<fn-select [editable]="true" placeholder="Select an option" label="Editable Selector" #selectEditableExample2>
14+
<li fn-option *ngFor="let option of options2" [value]="option" [label]="option.name"></li>
15+
</fn-select>
16+
</div>
17+
818
<p>
9-
<i>Editable Example selection: {{ selectEditableExample.value }}</i>
19+
<i>Editable Example selection: {{ selectEditableExample2.value | json }}</i>
1020
</p>

libs/docs/fn/select/examples/select-example/select-example-component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ import { Component } from '@angular/core';
66
})
77
export class SelectExampleComponent {
88
options: string[] = ['Apple', 'Pineapple', 'Kiwi', 'Tomato', 'Strawberry'];
9+
10+
options2: { name: string; kCal: string }[] = [
11+
{ name: 'Apple', kCal: '49.05' },
12+
{ name: 'Pineapple', kCal: '50' },
13+
{ name: 'Kiwi', kCal: '36' },
14+
{ name: 'Tomato', kCal: '24' },
15+
{ name: 'Strawberry', kCal: '32' }
16+
];
917
}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
<div style="width: 200px">
22
<fn-select placeholder="Select an option" label="Standard Selector" #selectExample1>
3-
<li fn-option *ngFor="let option of options" [value]="option">{{ option }}</li>
3+
<li fn-option *ngFor="let option of options" [value]="option" [label]="option"></li>
44
</fn-select>
55
</div>
6-
<br />
76

87
<p>
98
<i>selection: {{ selectExample1.value }}</i>
109
</p>
10+
<br />
11+
12+
<div style="width: 200px">
13+
<fn-select placeholder="Select an option" label="Standard Selector" #selectExample2>
14+
<li fn-option *ngFor="let option of options2" [value]="option" [label]="option.name"></li>
15+
</fn-select>
16+
</div>
17+
18+
<p>
19+
<i>selection: {{ selectExample2.value | json }}</i>
20+
</p>

0 commit comments

Comments
 (0)