Merge pull request #71 from abusix/update-deps #185
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "xarf-ci" | |
on: ["push", "pull_request"] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [14.x] | |
env: | |
NPM_CONFIG_PREFIX: "/home/runner/.npm-global" | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Add new global npm .bin to PATH | |
id: add_to_path | |
run: | | |
echo "/home/runner/.npm-global/bin/" >> $GITHUB_PATH | |
- name: Run ajv-cli to validate README documentation | |
id: validate_using_ajv_cli | |
run: | | |
npm install -g ajv-cli ajv-formats | |
ajv -c ajv-formats -s xarf.schema.json -d "samples/positive/**/*.json" -r "schemas/**/*.schema.json" | |
- name: Install dependencies | |
id: install_dependencies | |
run: | | |
npm install | |
- name: Lint and formatting check | |
id: linting | |
run: | | |
npx prettier --check . | |
npx eslint . | |
- name: Unit tests | |
id: run_tests | |
run: | | |
npm run test-xarf | |
- name: Bundle xarf and test bundled schemas | |
id: bundle | |
run: | | |
npm run bundle-xarf | |
ajv -c ajv-formats -s xarf_bundled.schema.json -d "samples/positive/**/*.json" | |
ajv -c ajv-formats -s xarf_deref.schema.json -d "samples/positive/**/*.json" | |
- name: Archive schemas | |
id: archive_schemas | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bundled-schema | |
path: | | |
xarf_bundled.schema.json | |
xarf_deref.schema.json | |
- name: Archive coverage | |
id: archive_coverage | |
uses: actions/upload-artifact@v2 | |
with: | |
name: coverage | |
path: | | |
coverage/ | |
.nyc_output/ | |
gen_validate_schema_pretty.js | |
release: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/master' | |
steps: | |
- name: Get current date | |
id: date | |
run: | | |
echo "CURRENT_DATETIME=$(date --utc +%Y%m%dT%H%M%SZ)" >> $GITHUB_ENV | |
- name: Debug release tag | |
id: debug_release_tag | |
run: | | |
echo "${{ env.CURRENT_DATETIME }}-${{ github.sha }}" | |
- name: Download bundled schemas from test build | |
uses: actions/download-artifact@v2 | |
with: | |
name: bundled-schema | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ env.CURRENT_DATETIME }}-${{ github.sha }} | |
release_name: Release ${{ env.CURRENT_DATETIME }}-${{ github.sha }} | |
draft: false | |
prerelease: false | |
- name: Upload XARF Bundled | |
id: upload-xarf-bundled | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./xarf_bundled.schema.json | |
asset_name: xarf_bundled.schema.json | |
asset_content_type: application/json | |
- name: Upload XARF Deref | |
id: upload-xarf-deref | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./xarf_deref.schema.json | |
asset_name: xarf_deref.schema.json | |
asset_content_type: application/json | |
report-coverage: | |
runs-on: ubuntu-latest | |
needs: test | |
steps: | |
- name: Download coverage from test build | |
uses: actions/download-artifact@v2 | |
with: | |
name: coverage | |
- uses: codecov/codecov-action@v4 | |
with: | |
fail_ci_if_error: true # optional (default = false) | |
verbose: true # optional (default = false) | |
token: ${{ secrets.CODECOV_TOKEN }} |