Skip to content

fix(ci): formatting for js client #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ runs:
run="true"
fi

echo "Running spec matrix: $run"
echo "Spec matrix: $(echo $matrix | jq .)"

echo "::set-output name=MATRIX::$matrix"
echo "::set-output name=RUN_SPECS::$run"

Expand All @@ -78,10 +81,14 @@ runs:
run="true"
fi

echo "Running javascript matrix: $run"
echo "Javascript matrix: $(echo $matrix | jq .)"

echo "::set-output name=MATRIX::$matrix"
echo "::set-output name=RUN_CLIENT::$run"

if [[ $base_changed == 'true' || steps.diff.outputs.JS_COMMON_CHANGED > 0 ]]; then
echo "Running common javascript: true"
echo "::set-output name=RUN_COMMON::true"
fi

Expand All @@ -99,6 +106,9 @@ runs:
run="true"
fi

echo "Running java matrix: $run"
echo "Java matrix: $(echo $matrix | jq .)"

echo "::set-output name=MATRIX::$matrix"
echo "::set-output name=RUN_CLIENT::$run"

Expand All @@ -116,6 +126,9 @@ runs:
run="true"
fi

echo "Running php matrix: $run"
echo "PHP matrix: $(echo $matrix | jq .)"

echo "::set-output name=MATRIX::$matrix"
echo "::set-output name=RUN_CLIENT::$run"

Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ jobs:
run: yarn cli build specs ${{ matrix.client }}

- name: Check diff with pushed spec
run: exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l)
run: |
git status
exit $(git status --porcelain specs/bundled/${{ matrix.client }}.yml | wc -l)

client_javascript_common:
timeout-minutes: 10
Expand Down Expand Up @@ -127,7 +129,9 @@ jobs:

- name: Check diff with pushed client
if: steps.cache.outputs.cache-hit != 'true'
run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l)
run: |
git status
exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l)

- name: Build ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -164,7 +168,9 @@ jobs:

- name: Check diff with pushed client
if: steps.cache.outputs.cache-hit != 'true'
run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l)
run: |
git status
exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l)

- name: Build ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -194,7 +200,9 @@ jobs:

- name: Check diff with pushed client
if: steps.cache.outputs.cache-hit != 'true'
run: exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l)
run: |
git status
exit $(git status --porcelain ${{ matrix.client.folder }} | wc -l)

- name: Build ${{ matrix.client.name }} client
if: steps.cache.outputs.cache-hit != 'true'
Expand All @@ -221,7 +229,9 @@ jobs:
run: yarn cli cts generate

- name: Check diff with pushed CTS
run: exit $(git status --porcelain ./tests/output | wc -l)
run: |
git status
exit $(git status --porcelain ./tests/output | wc -l)

- name: Run CTS
run: yarn cli cts run
Expand Down
9 changes: 8 additions & 1 deletion scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ export const ROOT_DIR = path.resolve(process.cwd(), '..');

export const GENERATORS = Object.fromEntries(
Object.entries(openapitools['generator-cli'].generators).map(([key, gen]) => {
return [key, { ...gen, ...splitGeneratorKey(key) }];
return [
key,
{
...gen,
output: gen.output.replace('#{cwd}/', ''),
...splitGeneratorKey(key),
},
];
})
);

Expand Down
12 changes: 6 additions & 6 deletions scripts/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ async function preGen(
{ language, client, key, output }: Generator,
verbose?: boolean
): Promise<void> {
const folder = output.replace('#{cwd}/', '');
await runIfExists(`./scripts/pre-gen/${language}.sh`, `${folder} ${key}`, {
await runIfExists(`./scripts/pre-gen/${language}.sh`, `${output} ${key}`, {
verbose,
});

Expand All @@ -31,8 +30,7 @@ async function postGen(
{ language, key, output }: Generator,
verbose?: boolean
): Promise<void> {
const folder = output.replace('#{cwd}/', '');
await runIfExists(`./scripts/post-gen/${language}.sh`, `${folder} ${key}`, {
await runIfExists(`./scripts/post-gen/${language}.sh`, `${output} ${key}`, {
verbose,
});
}
Expand All @@ -56,7 +54,7 @@ export async function generate(
spinner.text = `post-gen ${gen.key}`;
await postGen(gen, verbose);

if (gen.language === 'javascript' && CI) {
if (CI && gen.language === 'javascript') {
// because the CI is parallelized, run the formatter for each client
await formatter(gen.language, gen.output, verbose);
}
Expand All @@ -66,9 +64,11 @@ export async function generate(

const langs = [...new Set(generators.map((gen) => gen.language))];
for (const lang of langs) {
if (!CI || lang !== 'javascript') {
if (!(CI && lang === 'javascript')) {
await formatter(lang, getLanguageFolder(lang), verbose);
}

// build common packages
if (lang === 'javascript') {
const spinner = createSpinner(
'cleaning JavaScript client utils',
Expand Down