Skip to content

Commit 3fb1612

Browse files
Merge branch 'main' into draft-messages
2 parents 1e75f69 + 59c1a1f commit 3fb1612

File tree

10 files changed

+130
-29
lines changed

10 files changed

+130
-29
lines changed

.github/workflows/PR-SAP.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ concurrency:
99
group: pr-sap-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
1010
cancel-in-progress: true
1111

12+
permissions:
13+
contents: read
14+
1215
jobs:
1316
build-sap:
1417
runs-on: ubuntu-latest

.github/workflows/PR.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ concurrency:
88
group: pr-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
99
cancel-in-progress: true
1010

11+
permissions:
12+
contents: read
13+
1114
jobs:
1215
build:
1316
runs-on: ubuntu-latest

about/features.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,13 @@ Following is an index of the features currently covered by CAP, with status and
4747
| [Compile cds models to different outputs](../node.js/cds-compile) | `cds compile <models>` |
4848
| [Run your services in local server](../node.js/cds-serve) | `cds serve <services>` |
4949
| [Run and restart on file changes](../get-started/in-a-nutshell) | `cds watch` |
50-
| [Read-eval-event loop](../node.js/cds-env#cli) <!-- TODO --> | `cds repl` |
50+
| [Read-eval-event loop](../node.js/cds-env#cli) | `cds repl` |
5151
| Inspect effective configuration | `cds env` |
5252
| Prepare for deployment | `cds build` |
53-
| Deploy to databases or cloud | `cds deploy` |
53+
| Deploy to databases | `cds deploy` |
54+
| Build and deploy your application to the cloud | `cds up` |
55+
| Bind application to remote services | `cds bind` |
56+
| Debug your application | `cds debug` |
5457
| Login to multitenant SaaS application | `cds login <app-url>` |
5558
| Upgrade SaaS tenant(s) to latest versions | `cds upgrade` |
5659
| Logout from multitenant SaaS application | `cds logout` |
18.2 KB
Loading
29.3 KB
Loading

guides/deployment/cicd.md

Lines changed: 110 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,116 @@ status: released
1616
[[toc]]
1717

1818

19+
20+
21+
## GitHub Actions
22+
23+
GitHub offers continuous integration using [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration). In our [samples](https://github.com/capire/samples), we use simple workflows to [test, deploy and release new versions](https://github.com/capire/samples/tree/main/.github/workflows).
24+
25+
Add a default set of workflows to your project like so:
26+
27+
```sh
28+
cds add github-actions
29+
```
30+
> You can also use `cds add gha` as a shortcut.
31+
32+
### Deploy to Staging
33+
34+
The created workflows do a _Staging_ deployment for pushes on the `main` branch, for example after merging pull requests.
35+
36+
If no defaults are maintained in your GitHub org, a set of variables and secrets has to be provided. Open the repository and navigate here to maintain them:
37+
38+
`Settings``Secrets and variables``Actions`
39+
40+
For a minimal deployment setup, these variables and secrets are required:
41+
42+
#### Cloud Foundry
43+
44+
| **Type** | **Name** | **Note** | **Example** |
45+
|------------|----------------|-----------|-------------------|
46+
| Variable | `CF_API` | API URL | `https://api.cf.example.com` |
47+
| | `CF_USERNAME` | Username | `user@example.com` |
48+
| | `CF_ORG` | Org Name | `my-org` |
49+
| | `CF_SPACE` | Space Name| `my-space` |
50+
| Secret | `CF_PASSWORD` | Password | `********` |
51+
52+
#### Kyma
53+
54+
| **Type** | **Name** | **Note** | **Example** |
55+
|------------|----------------|-----------|-------------------|
56+
| Secret | `KUBE_CONFIG` | Base64-encoded Kubernetes config | see below |
57+
58+
59+
::: details Example of a decoded `KUBE_CONFIG`
60+
61+
Your `KUBE_CONFIG` will have to look similar to this. Make sure to replace `token` by an authorization token created for your technical user used for deployment.
62+
63+
```yaml{6-7,11}
64+
apiVersion: v1
65+
kind: Config
66+
clusters:
67+
- name: default-cluster
68+
cluster:
69+
certificate-authority-data: ...
70+
server: https://api.<server ID>.stage.kyma.ondemand.com
71+
users:
72+
- name: ci-user
73+
user:
74+
token: ...
75+
contexts:
76+
- name: ci-context
77+
context:
78+
cluster: default-cluster
79+
namespace: ci
80+
user: ci-user
81+
current-context: ci-context
82+
```
83+
[Learn more about configuring Kubernetes](./to-kyma#configure-kubernetes){.learn-more style="margin-top:20px"}
84+
85+
:::
86+
87+
#### BTP Prerequisites
88+
89+
Also make sure sufficient service entitlements are assigned to your subaccount depending on your expected usage.
90+
91+
::: tip Set up a sandbox subaccount as an org-wide default
92+
93+
Organization variables and secrets allow you to provide defaults for new projects without prior setup.
94+
95+
Once required for your use case, you can easily **overwrite org-wide** variables and secrets by **repository-local** ones.
96+
:::
97+
98+
#### You're set!
99+
100+
You can now simply push any CAP project that was set up using `cds add github-actions` to your org. When merging PRs or pushing to your `main` branch, the deployment workflow will start and after some time a new entry will show up in the _Deployments_ section on your repository front page:
101+
102+
![](./assets/github-deployment.png){style="max-width: 200px"} <!-- = image-width/2 -->
103+
104+
### Create a GitHub Release
105+
106+
#### Prerequisites
107+
108+
For the actual release we want to override org-wide sandbox variables to deploy to a different subaccount/organization and database.
109+
110+
Go to `Settings``Environments``New environment` → enter "Production".
111+
112+
Now override org-wide variables (e.g. `CF_ORG` and `CF_SPACE` in Cloud Foundry) to use a dedicated subaccount you created for the release deployment.
113+
114+
#### Publish the release
115+
116+
On your repository front page go to `Releases``Draft a new release``Select tag`.
117+
118+
Now enter a tag name, e.g. `v1.0.0` and select `Create new tag: v1.0.0 on publish`.
119+
120+
You can optionally add a release title and release notes. Hit **Publish release** once you're ready.
121+
122+
The release will show up in your _Releases_ page and a deployment to your production environment is started. Once finished, a _Production_ entry shows up next to _Staging_:
123+
124+
![](./assets/github-release.png){style="max-width: 268px"} <!-- = image-width/2 -->
125+
126+
127+
128+
19129
<span id="afterstart" />
20130

21131
<span id="beforecicd" />
@@ -35,8 +145,3 @@ For more flexibility you can set up continuous delivery in your software develop
35145
Try the tutorial [Create Automated System Tests for SAP Cloud Application Programming Model Projects](https://developers.sap.com/tutorials/cicd-wdi5-cap.html) to create system tests against a CAP-based sample application and automate your tests through a CI/CD pipeline.
36146

37147
[See a comparison with SAP Continuous Integration and Delivery Service.](https://www.project-piper.io/){.learn-more}
38-
39-
## GitHub Actions
40-
41-
GitHub offers continuous integration workflows using [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration). In our [SFlight sample,](https://github.com/SAP-samples/cap-sflight) we use GitHub Actions in two simple workflows to test our samples on [current Node.js and Java versions](https://github.com/SAP-samples/cap-sflight/tree/main/.github/workflows).
42-

guides/providing-services.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,6 @@ Searches the `title` element only.
394394

395395
##### Extend Search to *Associated* Entities
396396

397-
::: warning Node.js: Only w/ streamlined database services
398-
For Node.js projects, this feature is only available with the [streamlined `@cap-js/` database services](../releases/archive/2024/jun24#new-database-services-ga) (default with `@sap/cds` >= 8)
399-
:::
400-
401397
```cds
402398
@cds.search: { author }
403399
entity Books { ... }

tools/assets/help/cds-version-md.out.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| your-project | &lt;Add your repository here&gt; |
66
| ---------------------- | --------------------------------------- |
7-
| @sap/cds | 9.2.0 |
7+
| @sap/cds | 9.2.1 |
88
| @sap/cds-dk | -- missing -- |
99
| @sap/cds-compiler | 6.2.2 |
1010
| @sap/cds-dk (global) | 9.2.0 |

tools/assets/help/cds-version.out.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<pre class="log">
33
> cds version
44

5-
<em>@sap/cds</em>: 9.2.0
5+
<em>@sap/cds</em>: 9.2.1
66
<em>@sap/cds-dk</em>: undefined
77
<em>@sap/cds-compiler</em>: 6.2.2
88
<em>@sap/cds-dk (global)</em>: 9.2.0

tools/cds-lint/components/PlaygroundBadge.vue

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,12 @@ export default [
3333
3434
const defaultPackageJson = JSON.parse(data['package.json']);
3535
36-
function mergeJSONs(target: any, add: any) {
37-
const isObject = (obj: unknown) => typeof obj === 'object';
38-
Object.entries(add).forEach(([key, addVal]) => {
39-
const targetVal = target[key];
40-
if (targetVal && isObject(targetVal) && isObject(addVal)) {
41-
if ((Array.isArray(targetVal) && Array.isArray(addVal))) {
42-
targetVal.push(...addVal);
43-
return;
44-
}
45-
mergeJSONs(targetVal, addVal);
46-
} else {
47-
target[key] = addVal;
48-
}
49-
});
50-
return target;
36+
const is_object = x => typeof x === 'object' && x !== null && !Array.isArray(x)
37+
function merge (o:any,...xs:any) {
38+
let v:any; for (let x of xs) for (let k in x)
39+
if (k === '__proto__' || k === 'constructor') continue //> avoid prototype pollution
40+
else o[k] = is_object(v=x[k]) ? merge(o[k]??={},v) : v
41+
return o
5142
}
5243
5344
function link(name: Props['name'] = "", kind: Props['kind'], rules?: Props['rules'], files?: Props['files'], packages?: Props['packages'] ): string {
@@ -66,7 +57,7 @@ function link(name: Props['name'] = "", kind: Props['kind'], rules?: Props['rule
6657
sources[configFileName] = defaultConfig;
6758
}
6859
if (packages) {
69-
json = mergeJSONs(defaultPackageJson, packages);
60+
json = merge(defaultPackageJson, packages);
7061
} else {
7162
json = defaultPackageJson;
7263
}

0 commit comments

Comments
 (0)