Skip to content

Commit 226ee1d

Browse files
Merge pull request #19 from MiroslavDionisiev/gha-integration
Gha integration
2 parents cd16b40 + 3a2b153 commit 226ee1d

34 files changed

+343
-631
lines changed

.github/actions/install-dependencies/action.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,24 @@ runs:
2525
fi
2626
# When the main workflow calls many workspace workflows, we can reuse this cache for all of them.
2727
# Since this is caching the node_modules directory, DO NOT add partial-match restore keys!
28-
- uses: actions/cache/restore@v3
28+
- uses: actions/cache/restore@v4
2929
id: restore-node-modules-cache
3030
with:
3131
path: |
3232
node_modules
33-
workspaces/*/node_modules
33+
packages/*/node_modules
34+
packages/*/src/generated
3435
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
3536
- if: steps.restore-node-modules-cache.outputs.cache-hit != 'true'
3637
name: Install NPM dependencies
3738
working-directory: .
3839
shell: bash
3940
run: NODE_ENV=development npm ci
40-
- uses: actions/cache/save@v3
41+
- uses: actions/cache/save@v4
4142
if: steps.restore-node-modules-cache.outputs.cache-hit != 'true'
4243
with:
4344
path: |
4445
node_modules
45-
workspaces/*/node_modules
46+
packages/*/node_modules
47+
packages/*/src/generated
4648
key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Test package
2+
3+
inputs:
4+
package_name:
5+
description: The name of the tested package
6+
required: true
7+
8+
runs:
9+
using: composite
10+
steps:
11+
- name: Install Playwright
12+
shell: bash
13+
run: |
14+
if [[ ${{ inputs.package_name }} == "scratch-render" ]]; then
15+
npx playwright install --with-deps chromium
16+
fi
17+
- name: Test
18+
working-directory: ./packages/${{ inputs.package_name }}
19+
shell: bash
20+
run: |
21+
mkdir -p test-results
22+
npm run test | tee -a ./test-results/${{ inputs.package_name }}-test-results.txt
23+
- name: Store Test Results
24+
if: ${{ !cancelled() }}
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: ${{ inputs.package_name }}-test-output
28+
path: ./packages/${{ inputs.package_name }}/test-results/*

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}"
10+
cancel-in-progress: true
11+
12+
jobs:
13+
ci:
14+
name: Detect affected packages, build and test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
cache: 'npm'
21+
node-version-file: '.nvmrc'
22+
- uses: wagoid/commitlint-github-action@v5
23+
- name: Debug info
24+
run: |
25+
cat <<EOF
26+
Scratch environment: ${{ vars.SCRATCH_ENV || '<none>' }}
27+
Node version: $(node --version)
28+
NPM version: $(npm --version)
29+
GitHub ref: ${{ github.ref }}
30+
GitHub head ref: ${{ github.head_ref }}
31+
Working directory: $(pwd)
32+
EOF
33+
34+
- uses: dorny/paths-filter@v3
35+
id: filter
36+
with:
37+
filters: |
38+
any-workspace:
39+
- ".github/workflows/ci.yml"
40+
- "packages/**"
41+
scratch-svg-renderer:
42+
- ".github/workflows/ci.yml"
43+
- "packages/scratch-svg-renderer/**"
44+
scratch-render:
45+
- ".github/workflows/ci.yml"
46+
- "packages/scratch-render/**"
47+
- "packages/scratch-svg-renderer/**"
48+
scratch-vm:
49+
- ".github/workflows/ci.yml"
50+
- "packages/scratch-render/**"
51+
- "packages/scratch-svg-renderer/**"
52+
- "packages/scratch-vm/**"
53+
scratch-gui:
54+
- ".github/workflows/ci.yml"
55+
- "packages/scratch-gui/**"
56+
- "packages/scratch-render/**"
57+
- "packages/scratch-svg-renderer/**"
58+
- "packages/scratch-vm/**"
59+
60+
- if: ${{ steps.filter.outputs.any-workspace == 'true' }}
61+
uses: ./.github/actions/install-dependencies
62+
63+
- name: Build packages
64+
if: ${{ steps.filter.outputs.any-workspace == 'true' }}
65+
run: npm run build
66+
67+
- name: Test scratch-svg-renderer
68+
if: ${{ !cancelled() && steps.filter.outputs.scratch-svg-renderer == 'true' }}
69+
uses: ./.github/actions/test-package
70+
with:
71+
package_name: scratch-svg-renderer
72+
- name: Test scratch-render
73+
if: ${{ !cancelled() && steps.filter.outputs.scratch-render == 'true' }}
74+
uses: ./.github/actions/test-package
75+
with:
76+
package_name: scratch-render
77+
- name: Test scratch-vm
78+
if: ${{ !cancelled() && steps.filter.outputs.scratch-vm == 'true' }}
79+
uses: ./.github/actions/test-package
80+
with:
81+
package_name: scratch-vm
82+
- name: Test scratch-gui
83+
if: ${{ !cancelled() && steps.filter.outputs.scratch-gui == 'true' }}
84+
uses: ./.github/actions/test-package
85+
with:
86+
package_name: scratch-gui

packages/scratch-gui/.github/workflows/daily-tx-pull.yml renamed to .github/workflows/daily-tx-pull.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Daily Traslation Update
1+
name: Daily Translation Update
22
on:
33
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab
44
schedule:
@@ -11,11 +11,14 @@ permissions:
1111
jobs:
1212
daily-tx-pull:
1313
runs-on: ubuntu-latest
14+
defaults:
15+
run:
16+
working-directory: "./packages/scratch-gui"
1417
steps:
15-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
18+
- uses: actions/checkout@v4
1619
with:
1720
ref: 'develop'
18-
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
21+
- uses: actions/setup-node@v4
1922
with:
2023
cache: 'npm'
2124
node-version-file: '.nvmrc'

.github/workflows/publish.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
ci:
9+
uses: ./.github/workflows/ci.yml
10+
cd:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-node@v4
15+
with:
16+
cache: 'npm'
17+
node-version-file: '.nvmrc'
18+
19+
- name: Config GitHub user
20+
shell: bash
21+
run: |
22+
git config --global user.name 'GitHub Actions'
23+
git config --global user.email 'github-actions@localhost'
24+
25+
- name: Update the version in the package files
26+
shell: bash
27+
run: |
28+
GIT_TAG="${{github.event.release.tag_name}}"
29+
NEW_VERSION="${GIT_TAG/v/}"
30+
31+
bash ./scripts/update-dependencies-with-tag-versions.sh "$NEW_VERSION"
32+
git add package* && git commit -m "Release $NEW_VERSION"
33+
34+
- uses: ./.github/actions/install-dependencies
35+
36+
- name: Build packages
37+
run: npm run build
38+
39+
- name: Publish scratch-svg-renderer
40+
run: npm publish --access=public --workspace=@scratch/scratch-svg-renderer
41+
env:
42+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
43+
44+
- name: Publish scratch-render
45+
run: npm publish --access=public --workspace=@scratch/scratch-render
46+
env:
47+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
48+
49+
- name: Publish scratch-vm
50+
run: npm publish --access=public --workspace=@scratch/scratch-vm
51+
env:
52+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
53+
54+
- name: Publish scratch-gui
55+
run: npm publish --access=public --workspace=@scratch/scratch-gui
56+
env:
57+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
58+
59+
- name: Push to develop
60+
shell: bash
61+
run: |
62+
git fetch origin develop
63+
64+
TAG_NAME="${{github.event.release.tag_name}}"
65+
LAST_COMMIT_ID="$(git rev-parse $TAG_NAME)"
66+
DEVELOP_COMMIT_ID="$(git rev-parse origin/develop)"
67+
68+
if [ "$LAST_COMMIT_ID" = "$DEVELOP_COMMIT_ID" ]; then
69+
git push origin HEAD:develop
70+
else
71+
echo "Not pushing to develop because the tag we're operating on is behind"
72+
fi
73+
74+
# See https://stackoverflow.com/a/24849501
75+
- name: Change connected commit on release
76+
shell: bash
77+
run: |
78+
git tag -f "${{github.event.release.tag_name}}" HEAD
79+
git push -f origin "refs/tags/${{github.event.release.tag_name}}"
80+
81+
- name: Deploy scratch-svg-renderer to GitHub Pages
82+
uses: peaceiris/actions-gh-pages@v4
83+
with:
84+
github_token: ${{ secrets.GITHUB_TOKEN }}
85+
publish_dir: ./packages/scratch-svg-renderer/playground
86+
destination_dir: scratch-svg-renderer
87+
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
88+
89+
- name: Deploy scratch-render to GitHub Pages
90+
uses: peaceiris/actions-gh-pages@v4
91+
with:
92+
github_token: ${{ secrets.GITHUB_TOKEN }}
93+
publish_dir: ./packages/scratch-render/playground
94+
destination_dir: scratch-render
95+
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
96+
97+
- name: Deploy scratch-vm to GitHub Pages
98+
uses: peaceiris/actions-gh-pages@v4
99+
with:
100+
github_token: ${{ secrets.GITHUB_TOKEN }}
101+
publish_dir: ./packages/scratch-vm/playground
102+
destination_dir: scratch-vm
103+
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
104+
105+
- name: Deploy scratch-gui to GitHub Pages
106+
uses: peaceiris/actions-gh-pages@v4
107+
with:
108+
github_token: ${{ secrets.GITHUB_TOKEN }}
109+
publish_dir: ./packages/scratch-gui/build
110+
destination_dir: scratch-gui
111+
full_commit_message: "Build for ${{ github.sha }} ${{ github.event.head_commit.message }}"
112+
needs:
113+
- ci

packages/scratch-vm/.github/workflows/update-i18n.yml renamed to .github/workflows/update-i18n.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,14 @@ permissions:
1313
contents: write
1414

1515
jobs:
16-
ci-cd:
16+
update-i18n:
1717
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: "./packages/scratch-vm"
1821
steps:
19-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
20-
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
22+
- uses: actions/checkout@v4
23+
- uses: actions/setup-node@v4
2124
with:
2225
cache: 'npm'
2326
node-version-file: '.nvmrc'

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"scripts": {
1313
"refresh-gh-workflow": "ts-node scripts/build-gha-workflows.ts",
1414
"build-monorepo": "bash ./scripts/build-monorepo.sh",
15-
"prepare": "husky install"
15+
"prepare": "husky install",
16+
"build": "bash ./scripts/build-packages.sh"
1617
},
1718
"config": {
1819
"commitizen": {

0 commit comments

Comments
 (0)