Skip to content

Commit a20f67d

Browse files
authored
Merge pull request #25 from Telefonica/docs/sync-to-confluence
docs: Sync Markdown Confluence Sync docs
2 parents 349a282 + 940e0e2 commit a20f67d

File tree

16 files changed

+405
-36
lines changed

16 files changed

+405
-36
lines changed

.github/workflows/test-e2e.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# SPDX-FileCopyrightText: 2024 Telefónica Innovación Digital and contributors
2+
# SPDX-License-Identifier: MIT
3+
4+
name: Test E2E
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
markdown-confluence-sync-sync-docs:
16+
environment: production
17+
name: Markdown Confluence Sync Docs to Confluence
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Check out
22+
uses: actions/checkout@v4
23+
- uses: ./.github/actions/install
24+
- name: Sync Markdown Confluence Sync Docs to Confluence
25+
run: pnpm nx sync:docs markdown-confluence-sync
26+
env:
27+
CONFLUENCE_URL: ${{ vars.CONFLUENCE_URL }}
28+
CONFLUENCE_PAT: ${{ secrets.CONFLUENCE_PAT }}
29+
CONFLUENCE_ROOT_PAGE_ID: ${{ vars.CONFLUENCE_MARKDOWN_CONFLUENCE_SYNC_ROOT_PAGE_ID }}
30+
CONFLUENCE_SPACE_KEY: ${{ vars.CONFLUENCE_SPACE_KEY }}
31+
32+
markdown-confluence-sync-test-e2e:
33+
environment: production
34+
name: Test E2E Markdown Confluence Sync
35+
runs-on: ubuntu-latest
36+
needs: markdown-confluence-sync-sync-docs
37+
38+
steps:
39+
- name: Checkout
40+
id: checkout
41+
uses: actions/checkout@v4
42+
43+
- uses: ./.github/actions/install
44+
45+
- name: Run E2E Tests
46+
run: pnpm nx test:e2e markdown-confluence-sync
47+
env:
48+
CONFLUENCE_URL: ${{ vars.CONFLUENCE_URL }}
49+
CONFLUENCE_PAT: ${{ secrets.CONFLUENCE_PAT }}
50+
CONFLUENCE_ROOT_PAGE_ID: ${{ vars.CONFLUENCE_MARKDOWN_CONFLUENCE_SYNC_ROOT_PAGE_ID }}
51+
CONFLUENCE_SPACE_KEY: ${{ vars.CONFLUENCE_SPACE_KEY }}

components/markdown-confluence-sync/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ node_modules
77
# Generated
88
/coverage
99
/dist
10+
11+
# Env
12+
.env

components/markdown-confluence-sync/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
sync_to_confluence: true
3+
title: "[Markdown Confluence Sync] [TypeScript] Releases"
4+
---
5+
16
# Changelog
27

38
All notable changes to this project will be documented in this file.

components/markdown-confluence-sync/CONTRIBUTING.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ First of all, thank you for considering contributing to the this project! 🎉
1010
- [Monorepo tool](#monorepo-tool)
1111
- [Unit tests](#unit-tests)
1212
- [Component tests](#component-tests)
13+
- [E2E tests](#e2e-tests)
1314
- [Build](#build)
1415
- [NPM scripts reference](#npm-scripts-reference)
1516
- [License, Code of Conduct, and Contribution License Agreement](#license-code-of-conduct-and-contribution-license-agreement)
@@ -81,6 +82,31 @@ And, in a separate terminal:
8182
pnpm nx test:component:run markdown-confluence-sync
8283
```
8384

85+
### E2E tests
86+
87+
This component includes end-to-end tests, consisting in a workflow that uses the library to sync the documentation of the component itself to a Confluence page, and then it checks if the page was updated correctly.
88+
89+
To run tests locally, it requires the following environment variables to be set, which can be defined in a `.env` file:
90+
91+
```txt .env
92+
CONFLUENCE_URL=https://your-confluence-url.net
93+
CONFLUENCE_PAT=******
94+
CONFLUENCE_README_PAGE_ID=page-id-of-the-readme-page
95+
CONFLUENCE_SPACE_KEY=confluence-space-key
96+
```
97+
98+
Then, you should first run the synchronization with:
99+
100+
```bash
101+
pnpm nx sync:docs markdown-confluence-sync
102+
```
103+
104+
And finally, run the tests with:
105+
106+
```bash
107+
pnpm nx test:e2e markdown-confluence-sync
108+
```
109+
84110
### Build
85111

86112
This command generates the library into the `dist` directory. __Note that other components in the repository won't be able to use the library until this command is executed.__
@@ -94,6 +120,10 @@ pnpm nx build markdown-confluence-sync
94120
- `build` - Build the library.
95121
- `check:all` - Run all checks, tests, and build.
96122
- `test:unit` - Run unit tests.
123+
- `test:component` - Run component tests.
124+
- `confluence:mock` - Start the mock server, so you can run component tests separately in another terminal.
125+
- `test:component:run` - Run component tests without starting the mock server.
126+
- `test:e2e` - Run end-to-end tests.
97127
- `check:spell` - Checks spelling.
98128
- `check:types` - Checks the TypeScript types.
99129
- `lint` - Lint the code.
@@ -104,4 +134,4 @@ By contributing to this project, you agree that your contributions will be licen
104134

105135
## Pull requests
106136

107-
Please follow the recommendations in the main [CONTRIBUTING.md](../../.github/CONTRIBUTING.md) file in this repository before submitting a pull request.
137+
Please follow the recommendations in the main [CONTRIBUTING.md](../../.github/CONTRIBUTING.md) file in this repository before submitting a pull request.

components/markdown-confluence-sync/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
sync_to_confluence: true
3+
title: "[Markdown Confluence Sync] TypeScript"
4+
confluence_page_id: "337906335"
5+
---
6+
17
# markdown-confluence-sync
28

39
Creates/updates/deletes [Confluence](https://www.atlassian.com/es/software/confluence) pages based on markdown files in a directory. Supports Mermaid diagrams and per-page configuration using [frontmatter metadata](https://jekyllrb.com/docs/front-matter/). Works great with [Docusaurus](https://docusaurus.io/).
@@ -6,7 +12,7 @@ Creates/updates/deletes [Confluence](https://www.atlassian.com/es/software/confl
612

713
<details>
814
<summary>
9-
<strong>Details</strong>
15+
Details
1016
</summary>
1117

1218
- [Requirements](#requirements)

components/markdown-confluence-sync/eslint.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,23 @@ export default [
5252
},
5353
},
5454
},
55+
{
56+
...typescriptConfig,
57+
files: ["test/e2e/**/*.ts"],
58+
settings: {
59+
...typescriptConfig.settings,
60+
"import/resolver": {
61+
...typescriptConfig.settings["import/resolver"],
62+
},
63+
},
64+
},
5565
{
5666
...jestConfig,
5767
files: [
5868
...jestConfig.files,
5969
"test/unit/support/**/*.ts",
6070
"test/component/support/**/*.ts",
71+
"test/e2e/**/*.ts",
6172
],
6273
},
6374
{
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-FileCopyrightText: 2024 Telefónica Innovación Digital and contributors
2+
// SPDX-License-Identifier: MIT
3+
4+
// For a detailed explanation regarding each configuration property, visit:
5+
// https://jestjs.io/docs/en/configuration.html
6+
7+
module.exports = {
8+
// Automatically clear mock calls and instances between every test
9+
clearMocks: true,
10+
11+
// Indicates whether the coverage information should be collected while executing the test
12+
collectCoverage: false,
13+
14+
// The glob patterns Jest uses to detect test files
15+
testMatch: ["<rootDir>/test/e2e/specs/*.spec.ts"],
16+
17+
// The test environment that will be used for testing
18+
testEnvironment: "node",
19+
20+
setupFiles: ["<rootDir>/test/e2e/support/setup.ts"],
21+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
require("dotenv").config();
2+
3+
if (
4+
!process.env.CONFLUENCE_URL ||
5+
!process.env.CONFLUENCE_PAT ||
6+
!process.env.CONFLUENCE_SPACE_KEY ||
7+
!process.env.CONFLUENCE_ROOT_PAGE_ID
8+
) {
9+
throw new Error(
10+
"Please provide all required environment variables: CONFLUENCE_URL, CONFLUENCE_PAT, CONFLUENCE_SPACE_KEY, CONFLUENCE_ROOT_PAGE_ID",
11+
);
12+
}
13+
14+
module.exports = {
15+
mode: "flat",
16+
docsDir: ".",
17+
filesPattern: "*(README.md|CHANGELOG.md)",
18+
confluence: {
19+
url: process.env.CONFLUENCE_URL,
20+
personalAccessToken: process.env.CONFLUENCE_PAT,
21+
spaceKey: process.env.CONFLUENCE_SPACE_KEY,
22+
rootPageId: process.env.CONFLUENCE_ROOT_PAGE_ID,
23+
rootPageName: "Cross",
24+
},
25+
};

components/markdown-confluence-sync/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@
5050
"confluence:mock:ci": "mocks-server --no-plugins.inquirerCli.enabled",
5151
"lint": "eslint .",
5252
"lint:fix": "eslint . --fix",
53+
"sync:docs": "./bin/markdown-confluence-sync.mjs",
5354
"test:component": "start-server-and-test confluence:mock:ci http-get://127.0.0.1:3110/api/about test:component:run",
5455
"test:component:run": "jest --config jest.component.config.cjs --runInBand",
56+
"test:e2e": "jest --config jest.e2e.config.cjs",
5557
"test:unit": "jest --config jest.unit.config.cjs"
5658
},
5759
"nx": {
@@ -61,8 +63,10 @@
6163
"check:spell",
6264
"check:types",
6365
"lint",
66+
"sync:docs",
6467
"test:unit",
65-
"test:component"
68+
"test:component",
69+
"test:e2e"
6670
]
6771
},
6872
"dependencies": {
@@ -118,7 +122,9 @@
118122
"@types/unist": "2.0.11",
119123
"@types/which": "3.0.4",
120124
"babel-plugin-transform-import-meta": "2.2.1",
125+
"confluence.js": "1.7.4",
121126
"cross-fetch": "4.0.0",
127+
"dotenv": "16.4.6",
122128
"start-server-and-test": "2.0.8",
123129
"tmp": "0.2.3",
124130
"ts-dedent": "2.2.0",

components/markdown-confluence-sync/project.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@
5353
"{projectRoot}/bin/**/*",
5454
"{projectRoot}/config/**/*"
5555
]
56+
},
57+
"sync:docs": {
58+
"cache": false,
59+
"dependsOn": [
60+
"build"
61+
],
62+
"inputs": [
63+
{ "dependentTasksOutputFiles": "**/*", "transitive": true },
64+
"default",
65+
"production"
66+
],
67+
"outputs": []
5668
}
5769
},
5870
"implicitDependencies": [

0 commit comments

Comments
 (0)