Skip to content

Commit

Permalink
Merge branch 'master' into pfa
Browse files Browse the repository at this point in the history
  • Loading branch information
KhudaDad414 authored Jun 12, 2023
2 parents ff0e594 + 6bc610c commit 16bca37
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 3 deletions.
20 changes: 19 additions & 1 deletion .github/workflows/global-replicator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,22 @@ jobs:
committer_username: asyncapi-bot
committer_email: [email protected]
commit_message: "ci: update of files from global .github repo"
bot_branch_name: bot/update-files-from-global-repo
bot_branch_name: bot/update-files-from-global-repo

replicate_validate_workflow_schema:
if: startsWith(github.repository, 'asyncapi/')
name: Replicate workflow schema validation to repositories
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Replicating file
uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25
with:
github_token: ${{ secrets.GH_TOKEN }}
patterns_to_include: .github/workflows/validate-workflow-schema.yml
topics_to_include: get-workflows-validation
committer_username: asyncapi-bot
committer_email: [email protected]
commit_message: "ci: update of files from global .github repo"
bot_branch_name: bot/update-files-from-global-repo
4 changes: 2 additions & 2 deletions .github/workflows/if-nodejs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
run: npm install
- if: steps.packagejson.outputs.exists == 'true'
name: Add plugin for conventional commits for semantic-release
run: npm install [email protected]
run: npm install --save-dev [email protected]
- if: steps.packagejson.outputs.exists == 'true'
name: Publish to any of NPM, Github, and Docker Hub
id: release
Expand All @@ -123,4 +123,4 @@ jobs:
fields: repo,action,workflow
text: 'Release workflow failed in release job'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
72 changes: 72 additions & 0 deletions .github/workflows/validate-workflow-schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: YAML Lint Check

on:
pull_request:
branches:
- master
paths:
- '.github/workflows/**'

jobs:
yaml-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install Dependencies
run: npm install yaml-lint ajv axios js-yaml

- name: Lint YAML Files
run: |
set -e
find .github/workflows -type f -name "*.yml" -print0 | xargs -0 ./node_modules/.bin/yamllint -q
- name: List YAML files to validate
run: |
set -e
files=$(find .github/workflows -name '*.yml')
echo "Validating the following files:"
echo "$files"
- name: Run YAML validation
uses: actions/github-script@v6
with:
script: |
const Ajv = require("ajv");
const axios = require("axios");
const yaml = require("js-yaml");
const fs = require("fs").promises;
async function validateWorkflows() {
const schema = await axios.get(
"https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json"
);
const files = await fs.readdir(".github/workflows");
const ymlFiles = files.filter((file) => file.endsWith(".yml"));
for (const file of ymlFiles) {
try {
const content = await fs.readFile(`.github/workflows/${file}`, "utf8");
const target = yaml.load(content);
const ajv = new Ajv({ strict: false, allErrors: true });
const validator = ajv.compile(schema.data);
const valid = validator(target);
if (!valid) {
console.error(
`Validation failed for file '${file}' with the following errors:`
);
console.error(validator.errors);
process.exitCode = 1;
} else {
console.log(`Workflow in file '${file}' is valid`);
}
} catch (error) {
console.error(`Error validating file '${file}': ${error.message}`);
process.exitCode = 1;
}
}
}
validateWorkflows();
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@
</h1>

The purpose of this repository is to keep all the community health files that we would normally have to duplicate in each repository. These are global community files that apply to repositories that do not have their own files.

Below is a list of workflows with their corresponding topics and descriptions. By including each topic in your repository in AsyncAPI organisation, you will subscribe to get a workflow or a group of workflows that perform a specific task.

| Topic to include | Workflows you will get | Description |
| --- | --- | --- |
| `get-workflows-validation` | [validate-workflow-schema](.github/workflows/validate-workflow-schema.yml) | Validates the YAML schema of a workflow files in your repository
| `golang` | [if-go-pr-testing](.github/workflows/if-go-pr-testing.yml) | Compiles and tests Go code using multiple versions of Go
| `nodejs` | [if-nodejs-pr-testing](.github/workflows/if-nodejs-pr-testing.yml) | Builds and tests Node.js projects using multiple Node.js versions
| `get-global-node-release-workflows` | [if-nodejs-release](.github/workflows/if-nodejs-release.yml), [if-nodejs-version-bump.yml](.github/workflows/if-nodejs-version-bump.yml) , [bump.yml](.github/workflows/bump.yml) | Fetches and publishes Node.js release information to the project's website
| `get-global-releaserc` | [.releaserc](.github/workflows/.releaserc) | Fetches release configuration files from a remote repository and makes them available to other workflows

0 comments on commit 16bca37

Please sign in to comment.