forked from scratchfoundation/scratch-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (120 loc) · 4.37 KB
/
ci.yml
File metadata and controls
130 lines (120 loc) · 4.37 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
name: CI
on:
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
push: # Runs whenever a commit is pushed to the repository
branches: [experience-cs]
permissions:
packages: write # deploy to GitHub Packages
contents: read # The following 4 permissions are needed to publish test results
issues: read
checks: write
pull-requests: write
concurrency:
group: "${{ github.workflow }} @ ${{ github.event.compare || github.head_ref || github.ref }}"
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
any-workspace: ${{ steps.filter.outputs.any-workspace }}
packages: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
cache: "npm"
node-version-file: ".nvmrc"
registry-url: "https://npm.pkg.github.com"
- uses: wagoid/commitlint-github-action@9763196e10f27aef304c9b8b660d31d97fce0f99 # v5
- name: Debug info
# https://docs.github.com/en/actions/reference/security/secure-use#use-an-intermediate-environment-variable
env:
# `env:` values are printed to the log even without using them in `run:`
GH_CONTEXT: ${{ toJson(github) }}
run: |
cat <<EOF
Working directory: $(pwd)
Node version: $(node --version)
NPM version: $(npm --version)
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
EOF
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
filters: ./.github/path-filters.yml
- if: ${{ steps.filter.outputs.any-workspace == 'true' }}
env:
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/actions/install-dependencies
- name: Explicitly install Rolldown linux binaries
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
run: npm install @rolldown/binding-linux-x64-gnu --no-save --ignore-scripts
- name: Build packages
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
run: npm run build
- name: Store build artifacts
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5
with:
name: build
path: |
packages/**/build
packages/**/dist
packages/**/playground
- name: Publish scratch-gui to GitHub Packages
working-directory: ./packages/scratch-gui
env:
NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_VERSION="0.1.0-experience-cs.$(date +'%Y%m%d%H%M%S')"
npm version --no-git-tag-version $RELEASE_VERSION
npm publish --access public --tag latest
test:
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.any-workspace == 'true' }}
strategy:
fail-fast: false
matrix:
package: ${{ fromJSON(needs.build.outputs.packages) }}
exclude:
- package: global
- package: any-workspace
name: Test ${{ matrix.package }}
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6
with:
cache: "npm"
node-version-file: ".nvmrc"
- uses: ./.github/actions/install-dependencies
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6
with:
name: build
path: packages
- uses: ./.github/actions/test-package
with:
package_name: ${{ matrix.package }}
results:
name: Test Results
runs-on: ubuntu-latest
needs: test
if: ${{ !cancelled() }}
steps:
- run: |
case "${{ needs.test.result }}" in
success)
echo "Tests passed successfully."
exit 0
;;
skipped)
echo "Tests were unnecessary for these changes, so they were skipped."
echo "If this is unexpected, check the path filters."
exit 0
;;
*)
echo "Tests failed."
exit 1
;;
esac