Skip to content

Commit

Permalink
improved formatting of fail output
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvuka1 committed May 20, 2024
1 parent b77d74b commit 1edfa3e
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 79 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ jobs:
id: test-action
uses: ./
with:
openapi-path:
${{ github.workspace }}/__tests__/data/custom/basic/openapi.json
doc-path: ${{ github.workspace }}/__tests__/data/custom/basic/api.md
openapi-path: __tests__/data/custom/basic/openapi.json
doc-path: __tests__/data/custom/basic/api.md
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,5 @@ __tests__/runner/*
*.code-workspace

__tests__/data/repos/**
__tests__/**.md
!__tests__/data/repos/.gitkeep
7 changes: 3 additions & 4 deletions __tests__/repos/alibaba__GraphScope.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe('action', () => {
it('handles alibaba/GraphScope', async () => {
await setupInputRepo(getInputMock, {
repoName: 'alibaba/GraphScope',
urlOpenApi:
'https://github.com/alibaba/GraphScope/blob/f15605b083ac92c6a8bf33ed6bb44616eae30a03/flex/openapi/openapi_interactive.yaml',
urlDoc:
'https://github.com/alibaba/GraphScope/blob/f15605b083ac92c6a8bf33ed6bb44616eae30a03/docs/flex/interactive/development/restful_api.md',
sha: 'bf4bd712041a04ce3adba56939a5bccaad13e137',
pathOas: 'flex/openapi/openapi_interactive.yaml',
pathDoc: 'docs/flex/interactive/development/restful_api.md',
});

await main.run();
Expand Down
7 changes: 3 additions & 4 deletions __tests__/repos/backstage__backstage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe('action', () => {
it('handles backstage/backstage', async () => {
await setupInputRepo(getInputMock, {
repoName: 'backstage/backstage',
urlOpenApi:
'https://github.com/backstage/backstage/blob/2f6e3e6b47d7c710ef8f137625699080cda8cb79/plugins/catalog-backend/src/schema/openapi.yaml',
urlDoc:
'https://github.com/backstage/backstage/blob/2f6e3e6b47d7c710ef8f137625699080cda8cb79/docs/features/software-catalog/api.md',
sha: '2c3f493ee32d67d3a300d13e73e352f91145a3ee',
pathOas: 'plugins/catalog-backend/src/schema/openapi.yaml',
pathDoc: 'docs/features/software-catalog/api.md',
});

await main.run();
Expand Down
7 changes: 3 additions & 4 deletions __tests__/repos/fleetdm__fleet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe('action', () => {
it('handles fleetdm/fleet', async () => {
await setupInputRepo(getInputMock, {
repoName: 'fleetdm/fleet',
urlOpenApi:
'https://github.com/fleetdm/fleet/blob/2dd7b6e5644fc8fea045b0ea37f51225b801f105/server/mdm/nanodep/docs/openapi.yaml',
urlDoc:
'https://github.com/fleetdm/fleet/blob/2dd7b6e5644fc8fea045b0ea37f51225b801f105/server/mdm/nanodep/docs/operations-guide.md',
sha: '2dd7b6e5644fc8fea045b0ea37f51225b801f105',
pathOas: 'server/mdm/nanodep/docs/openapi.yaml',
pathDoc: 'server/mdm/nanodep/docs/operations-guide.md',
});

await main.run();
Expand Down
7 changes: 3 additions & 4 deletions __tests__/repos/gothinkster__realworld.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe('action', () => {
it('handles gothinkster/realworld', async () => {
await setupInputRepo(getInputMock, {
repoName: 'gothinkster/realworld',
urlOpenApi:
'https://github.com/gothinkster/realworld/blob/11c81f64f04fff8cfcd60ddf4eb0064c01fa1730/api/openapi.yml',
urlDoc:
'https://github.com/gothinkster/realworld/blob/11c81f64f04fff8cfcd60ddf4eb0064c01fa1730/apps/documentation/docs/specs/backend-specs/endpoints.md',
sha: '11c81f64f04fff8cfcd60ddf4eb0064c01fa1730',
pathOas: 'api/openapi.yml',
pathDoc: 'apps/documentation/docs/specs/backend-specs/endpoints.md',
});

await main.run();
Expand Down
7 changes: 3 additions & 4 deletions __tests__/repos/openstf__stf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe('action', () => {
it('handles openstf/stf', async () => {
await setupInputRepo(getInputMock, {
repoName: 'openstf/stf',
urlOpenApi:
'https://github.com/openstf/stf/blob/2b9649009722794dee9efd32b71bccbcbfe9d794/lib/units/api/swagger/api_v1_generated.json',
urlDoc:
'https://github.com/openstf/stf/blob/2b9649009722794dee9efd32b71bccbcbfe9d794/doc/API.md',
sha: '2b9649009722794dee9efd32b71bccbcbfe9d794',
pathOas: 'lib/units/api/swagger/api_v1_generated.json',
pathDoc: 'doc/API.md',
});

await main.run();
Expand Down
12 changes: 6 additions & 6 deletions __tests__/repos/stacks-network__stacks-core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ describe('action', () => {

it('handles stacks-network/stacks-core', async () => {
const repoName = 'stacks-network/stacks-core';
const sha = 'b7f7295775ba8571ed322846367451fc6bf44126';
await setupInputRepo(getInputMock, {
repoName,
urlOpenApi:
'https://github.com/stacks-network/stacks-core/blob/b7f7295775ba8571ed322846367451fc6bf44126/docs/rpc/openapi.yaml',
urlDoc:
'https://github.com/stacks-network/stacks-core/blob/b7f7295775ba8571ed322846367451fc6bf44126/docs/rpc-endpoints.md',
sha,
pathOas: 'docs/rpc/openapi.yaml',
pathDoc: 'docs/rpc-endpoints.md',
});

const apiDirs = ['contract', 'core-node', 'trait', 'transaction'];
Expand Down Expand Up @@ -103,13 +103,13 @@ describe('action', () => {
...a.map(([dir, filePath]) =>
getOrDownload(
repoName,
`https://github.com/stacks-network/stacks-core/blob/b7f7295775ba8571ed322846367451fc6bf44126/docs/rpc/api/${filePath}`,
`https://github.com/${repoName}/blob/${sha}/docs/rpc/api/${filePath}`,
dir,
),
),
getOrDownload(
repoName,
`https://github.com/stacks-network/stacks-core/blob/b7f7295775ba8571ed322846367451fc6bf44126/docs/rpc/entities/contracts/read-only-function-args.schema.json`,
`https://github.com/${repoName}/blob/${sha}/docs/rpc/entities/contracts/read-only-function-args.schema.json`,
entitiesContractsDir,
),
]);
Expand Down
7 changes: 3 additions & 4 deletions __tests__/repos/sunflower-land__sunflower-land.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ describe('action', () => {
it('handles sunflower-land/sunflower-land', async () => {
await setupInputRepo(getInputMock, {
repoName: 'sunflower-land/sunflower-land',
urlOpenApi:
'https://github.com/sunflower-land/sunflower-land/blob/877234bda1c498505a9be75b83affb487285af5c/docs/openapi.json',
urlDoc:
'https://github.com/sunflower-land/sunflower-land/blob/877234bda1c498505a9be75b83affb487285af5c/docs/OFFCHAIN_API.md',
sha: '877234bda1c498505a9be75b83affb487285af5c',
pathOas: 'docs/openapi.json',
pathDoc: 'docs/OFFCHAIN_API.md',
});

await main.run();
Expand Down
22 changes: 14 additions & 8 deletions __tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,35 @@ export const setupInput = (

type RepoInfo = {
repoName: string;
urlDoc: string;
urlOpenApi: string;
sha: string;
pathDoc: string;
pathOas: string;
};

export const setupInputRepo = async (
getInputMock: GetInputMock,
repoInfo: RepoInfo,
) => {
const { repoName, urlDoc, urlOpenApi } = repoInfo;
const [pathOpenApi, docPath] = await Promise.all([
getOrDownload(repoName, urlOpenApi),
getOrDownload(repoName, urlDoc),
const { repoName, pathDoc, pathOas, sha } = repoInfo;
const githubBase = `https://github.com/${repoName}/blob/${sha}`;
const pathOasGithub = `${githubBase}/${pathOas}`;
const pathDocGithub = `${githubBase}/${pathDoc}`;
const [pathOasLocal, pathDocLocal] = await Promise.all([
getOrDownload(repoName, pathOasGithub),
getOrDownload(repoName, pathDocGithub),
]);
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'openapi-path':
return pathOpenApi;
return pathOasLocal;
case 'doc-path':
return docPath;
return pathDocLocal;
default:
return '';
}
});
process.env.OAS_PATH = pathOasGithub;
process.env.DOC_PATH = pathDocGithub;
};

export const getOrDownload = async (
Expand Down
59 changes: 41 additions & 18 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1edfa3e

Please sign in to comment.