-
Notifications
You must be signed in to change notification settings - Fork 19
118 lines (117 loc) · 3.8 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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@v4
with:
name: bundled-schema
path: |
xarf_bundled.schema.json
xarf_deref.schema.json
- name: Archive coverage
id: archive_coverage
uses: actions/upload-artifact@v4
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/[email protected]
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/[email protected]
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 }}