mirror of
https://github.com/yanhao98/composite-actions.git
synced 2025-07-13 06:40:49 +08:00
131 lines
3.3 KiB
YAML
131 lines
3.3 KiB
YAML
on:
|
|
pull_request:
|
|
paths:
|
|
- "setup-node-environment/**"
|
|
- ".github/workflows/setup-node-environment-test.yaml"
|
|
push:
|
|
paths:
|
|
- "setup-node-environment/**"
|
|
- ".github/workflows/setup-node-environment-test.yaml"
|
|
env:
|
|
TZ: Asia/Shanghai
|
|
package_json_content: |
|
|
{
|
|
"packageManager": "pnpm@10.6.5",
|
|
"dependencies": {
|
|
"bun": "^1.2.5"
|
|
}
|
|
}
|
|
|
|
concurrency:
|
|
group: ${{ github.event_name }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
generate_lock:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
lock_file_content: ${{ steps.generate_lock.outputs.lock_file_content }}
|
|
steps:
|
|
- uses: pnpm/action-setup@v4
|
|
with:
|
|
version: latest
|
|
standalone: true
|
|
- id: generate_lock
|
|
env:
|
|
CI: 'false'
|
|
run: |
|
|
set -x;
|
|
cat <<EOF > package.json
|
|
${{ env.package_json_content }}
|
|
EOF
|
|
pnpm config list
|
|
cat package.json
|
|
pnpm install --lockfile-only
|
|
echo "lock_file_content<<EOF" >> $GITHUB_OUTPUT
|
|
cat pnpm-lock.yaml >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
tests:
|
|
needs: generate_lock
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
container:
|
|
- 'yanhao98/runner-images:pnpm'
|
|
- '' # gitea/runner-images:ubuntu-latest
|
|
npmrc_content:
|
|
- ''
|
|
- |
|
|
use-node-version=22.14.0 # https://pnpm.io/zh/npmrc#use-node-version
|
|
lock_file:
|
|
- 'true'
|
|
- 'false'
|
|
cwd:
|
|
- ''
|
|
- 'test'
|
|
container: ${{ matrix.container }}
|
|
steps:
|
|
# - uses: actions/checkout@main
|
|
- name: 打印 matrix
|
|
run: |
|
|
echo "🤖---- 打印 matrix ----🤖"
|
|
echo "container: ${{ matrix.container }}"
|
|
echo "npmrc_content: ${{ matrix.npmrc_content }}"
|
|
echo "lock_file: ${{ matrix.lock_file }}"
|
|
echo "cwd: ${{ matrix.cwd }}"
|
|
echo "GITHUB_WORKSPACE: ${{ github.workspace }}"
|
|
|
|
- name: Create test directory
|
|
if: matrix.cwd != ''
|
|
run: |
|
|
mkdir -p ${{ matrix.cwd }}
|
|
set -x;
|
|
ls -l -R .
|
|
pwd
|
|
|
|
- name: Create .npmrc
|
|
working-directory: ${{ matrix.cwd }}
|
|
if: matrix.npmrc_content != ''
|
|
run: |
|
|
cat <<EOF > .npmrc
|
|
${{ matrix.npmrc_content }}
|
|
EOF
|
|
set -x;
|
|
ls -l -R .
|
|
pwd
|
|
cat .npmrc
|
|
|
|
- name: Create package.json
|
|
working-directory: ${{ matrix.cwd }}
|
|
run: |
|
|
mkdir -p ${{ github.workspace }}/.git
|
|
cat <<EOF > package.json
|
|
${{ env.package_json_content }}
|
|
EOF
|
|
set -x;
|
|
ls -l -R .
|
|
pwd
|
|
cat package.json
|
|
|
|
- name: Create pnpm-lock.yaml
|
|
working-directory: ${{ matrix.cwd }}
|
|
if: matrix.lock_file == 'true'
|
|
run: |
|
|
cat <<EOF > pnpm-lock.yaml
|
|
${{ needs.generate_lock.outputs.lock_file_content }}
|
|
EOF
|
|
set -x;
|
|
ls -l -R .
|
|
pwd
|
|
cat pnpm-lock.yaml
|
|
|
|
- uses: yanhao98/composite-actions/setup-node-environment@main
|
|
with:
|
|
working-directory: ${{ matrix.cwd }}
|