Skip to content

Commit

Permalink
feat: wip merge not working yet
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleJohnst committed Nov 26, 2024
2 parents 924326c + 589d49b commit df41532
Show file tree
Hide file tree
Showing 162 changed files with 14,812 additions and 13,000 deletions.
24 changes: 9 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
build:
working_directory: /mnt/ramdisk/project
docker:
- image: cimg/node:16.17
- image: cimg/node:18.20
resource_class: xlarge
environment:
CYPRESS_CACHE_FOLDER: /mnt/ramdisk/.cache/Cypress
Expand All @@ -47,7 +47,7 @@ jobs:
- run: yarn build.docs
run-e2e-tests:
executor: cypress-default
resource_class: large
resource_class: xlarge
working_directory: /mnt/ramdisk/project
environment:
CYPRESS_CACHE_FOLDER: /mnt/ramdisk/.cache/Cypress
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
command: weekly_lockfile_maintenance.sh
release:
docker:
- image: cimg/node:16.17
- image: cimg/node:18.20
steps:
- checkout
- run:
Expand All @@ -117,11 +117,6 @@ workflows:
example-name: react-cra
requires:
- build
- run-e2e-tests:
name: e2e-react-gatsby
example-name: react-gatsby
requires:
- build
- run-e2e-tests:
name: e2e-angular
example-name: angular
Expand All @@ -138,7 +133,6 @@ workflows:
- build
- build-docs
- e2e-react-cra
- e2e-react-gatsby
- e2e-static-html
- e2e-angular
filters:
Expand All @@ -147,11 +141,11 @@ workflows:
- main
perform-lockfile-maintenance:
triggers:
- schedule:
cron: "0 3 * * 1"
filters:
branches:
only:
- main
- schedule:
cron: '0 3 * * 1'
filters:
branches:
only:
- main
jobs:
- lockfile-maintenance
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: npm
directory: '/'
schedule:
interval: 'daily'
25 changes: 25 additions & 0 deletions .github/workflows/auto-approve.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Auto Approve DependaBot PRs

on:
pull_request:
branches:
- main

permissions:
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
26 changes: 26 additions & 0 deletions .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Auto Merge Dependabot PRs
on:
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: '${{ secrets.GITHUB_TOKEN }}'
- name: Enable auto-merge for Dependabot PRs
if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}}
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
13 changes: 13 additions & 0 deletions .github/workflows/jira-issue-label-added.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Jira Issue Label Added

on:
issues:
types:
- labeled

jobs:
call-workflow:
uses: stoplightio/.github/.github/workflows/jira-issue-label-added.yaml@master
with:
team-name: ${{ contains(github.event.pull_request.labels.*.name, 'team/bad-news-bears') && 'Bad News Bears' || contains(github.event.pull_request.labels.*.name, 'team/maintenance') && 'Maintenance' || '' }}
secrets: inherit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ dist-storybook
*.log*
*-debug.log*
*-error.log*
/examples/react-gatsby/yarn.lock
/examples/react-cra/yarn.lock
/examples/angular/yarn.lock

Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

17 changes: 17 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { defineConfig } from 'cypress';

export default defineConfig({
reporter: 'junit',
reporterOptions: {
mochaFile: 'cypress/results/output.xml',
toConsole: false,
},
screenshotsFolder: 'cypress/results/screenshots',
videosFolder: 'cypress/results/videos',
e2e: {
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config);
},
baseUrl: 'http://localhost:4200/',
},
});
11 changes: 0 additions & 11 deletions cypress.json

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,31 @@ describe('Stoplight component', () => {
});

it('invokes TryIt request', () => {
loadCreateTodoPage();
loadListTodosPage();

cy.intercept(
{
method: 'GET',
hostname: 'todos.stoplight.io',
pathname: '/**',
https: true,
},
{
statusCode: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'content-type',
'Content-Type': 'application/json',
},
body: '"hello world"',
},
).as('todos-api');

cy.findByRole('button', { name: /send api request/i }).click();

// Temporarily changing response code as the requested api is unavailable
cy.findByText('500 Internal Server Error').should('exist');
cy.wait('@todos-api');

cy.findByText('hello world').should('exist');
});

it('mocks response correctly', () => {
Expand All @@ -72,7 +92,9 @@ describe('Stoplight component', () => {
cy.findByRole('menuitemradio', { name: /mock server/i }).then(enabled => {
enabled.trigger('click');
});
cy.intercept('https://stoplight.io/mocks/**').as('getData');
cy.findByRole('button', { name: /send api request/i }).click();
cy.wait('@getData');
cy.findByText('200 OK').should('exist');
});
});
Expand Down Expand Up @@ -111,8 +133,10 @@ describe('Stoplight component', () => {

function loadStoplightProjectPage() {
cy.intercept('https://stoplight.io/api/v1/projects/cHJqOjYwNjYx/nodes/**').as('getNode');
cy.intercept(`https://stoplight.io/api/v1/projects/cHJqOjYwNjYx/table-of-contents`).as('getToc');
cy.visit('/stoplight-project');
cy.wait('@getNode');
cy.wait('@getToc');
}

function loadCreateTodoPage() {
Expand All @@ -132,7 +156,9 @@ function loadMarkdownPage() {
}

function visitNode(nodeId: string, nodeSlug: string) {
cy.intercept(`https://stoplight.io/api/v1/projects/cHJqOjYwNjYx/nodes/${nodeId}`).as('getNode');
cy.intercept(`https://stoplight.io/api/v1/projects/cHJqOjYwNjYx/nodes/${nodeId}-${nodeSlug}`).as('getNode');
cy.intercept(`https://stoplight.io/api/v1/projects/cHJqOjYwNjYx/table-of-contents`).as('getToc');
cy.visit(`/stoplight-project/${nodeId}-${nodeSlug}`);
cy.wait('@getNode');
cy.wait('@getToc');
}
File renamed without changes.
44 changes: 44 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,47 @@
4. Open `http://localhost:4025` in your browser.

Changes to the demo or other packages in this repo will cause the demo to reload.


#### Troubleshooting Elements-Dev-Portal

If you are wanting to troubleshoot the `StoplightProject` component with the demo app, you will need to make the following changes:

1. Set the contents of the index.tsx to the following, replacing/adding properties as needed for your use case:
```
import '@stoplight/elements-core/styles.css';
import { StoplightProject } from '@stoplight/elements-dev-portal';
import { subscribeTheme } from '@stoplight/mosaic';
import React from 'react';
import ReactDOM from 'react-dom';
subscribeTheme();
ReactDOM.render(
<React.StrictMode>
<StoplightProject projectId="projectId" router="history"></StoplightProject>
</React.StrictMode>,
document.getElementById('root'),
);
```
2. Update the package.js to include the new dependency
`"@stoplight/elements-dev-portal": "^2.0.0",`

3. To ensure the local elements-dev-portal package is included and the app reloads on change, update the common.js webpack file to include the package.
```
...
const absoluteElementsDevPortalPath = resolve(__dirname, '../../packages/elements-dev-portal/src');
...
module.exports = {
...
resolve: {
...
alias: {
...
'@stoplight/elements-dev-portal': absoluteElementsDevPortalPath,
...
```
4. Additionally update the .babelrc module resolver to include `"@stoplight/elements-dev-portal": "../packages/elements-dev-portal/src"
`
8 changes: 4 additions & 4 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"history": "^5.0.0",
"react": "16.14.0",
"react-dom": "16.14.0",
"react-github-btn": "1.2.2",
"react-github-btn": "1.4.0",
"react-router-dom": "6.0.0-beta.0"
},
"devDependencies": {
Expand All @@ -26,19 +26,19 @@
"@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0",
"eslint": "^7.23.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.23.1",
"express": "^4.17.3",
"html-webpack-plugin": "^5.3.2",
"jest": "^26.6.3",
"mini-css-extract-plugin": "^1.4.0",
"mini-css-extract-plugin": "^2.9.0",
"prettier": "^2.2.1",
"process": "0.11.10",
"rimraf": "^3.0.2",
"ts-loader": "^9.2.8",
"webpack": "^5.59.1",
"webpack-cli": "^4.9.1",
"webpack-cli": "^5.1.4",
"webpack-merge": "^5.7.3"
}
}
5 changes: 4 additions & 1 deletion demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ export function App() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const isStacked = searchParams.get('layout') === 'stacked';

const [globalState, setGlobalState] = useState<GlobalContext>({
apiDescriptionUrl: searchParams.get('spec') || DEFAULT_API_URL,
setDescriptionUrl: _value => {
const value = _value.trim() || DEFAULT_API_URL;

let nextUrl = '/';
if (value && value !== DEFAULT_API_URL) {
nextUrl = `?spec=${value}`;
nextUrl = `?spec=${value}${isStacked ? '&layout=stacked' : ''}`;
}

window.history.pushState(undefined, '', nextUrl);
Expand All @@ -35,6 +37,7 @@ export function App() {
});
}, 0);
},
layout: isStacked ? 'stacked' : undefined,
});

return (
Expand Down
6 changes: 3 additions & 3 deletions demo/src/components/ElementsAPI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ import React, { useContext } from 'react';
import { GlobalContext } from '../context';

export const ElementsAPI: React.FC = () => {
const { apiDescriptionUrl } = useContext(GlobalContext);
const { apiDescriptionUrl, layout } = useContext(GlobalContext);

const specUrlWithProxy =
apiDescriptionUrl && window.location.origin === 'https://elements-demo.stoplight.io'
? `https://stoplight.io/cors-proxy/${apiDescriptionUrl}`
: apiDescriptionUrl;

return (
<Box flex={1} overflowY="hidden">
<API apiDescriptionUrl={specUrlWithProxy} router="hash" />
<Box flex={1} overflowY={layout !== 'stacked' ? 'hidden' : undefined}>
<API apiDescriptionUrl={specUrlWithProxy} router="hash" layout={layout} />
</Box>
);
};
Loading

0 comments on commit df41532

Please sign in to comment.