|
1 | | -name: Daffodil Daff CLI |
| 1 | +name: Daffodil Daff Config |
2 | 2 |
|
3 | 3 | on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - develop |
4 | 7 | workflow_call: |
5 | 8 | inputs: |
6 | 9 | ref: |
|
13 | 16 | angular-version: |
14 | 17 | required: false |
15 | 18 | type: string |
16 | | - default: '^20' |
| 19 | + description: "Angular version constraint (e.g. '^20'). Defaults to the @angular/core version in package.json." |
17 | 20 | secrets: |
18 | 21 | NX_KEY: |
19 | 22 | required: true |
|
28 | 31 |
|
29 | 32 | jobs: |
30 | 33 | test: |
31 | | - name: "daff CLI (${{ matrix.driver }}, @angular${{ inputs.angular-version }})" |
| 34 | + name: "daff.json (${{ matrix.driver }})" |
32 | 35 | runs-on: ubuntu-latest |
33 | 36 | services: |
34 | 37 | verdaccio: |
|
51 | 54 | fetch-depth: 1 |
52 | 55 | ref: ${{ inputs.ref && inputs.ref || github.sha }} |
53 | 56 |
|
| 57 | + - name: Resolve Angular version |
| 58 | + id: angular-version |
| 59 | + env: |
| 60 | + INPUT_VERSION: ${{ inputs.angular-version }} |
| 61 | + run: | |
| 62 | + if [ -n "$INPUT_VERSION" ]; then |
| 63 | + VERSION="$INPUT_VERSION" |
| 64 | + else |
| 65 | + VERSION=$(jq -r '.dependencies["@angular/core"]' package.json | sed -E 's/\.[0-9]+\.[0-9]+//g') |
| 66 | + fi |
| 67 | + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" |
| 68 | +
|
54 | 69 | - uses: graycoreio/github-actions/setup-node@main |
55 | 70 | with: |
56 | 71 | node-version: ${{ inputs.node-version }} |
@@ -106,17 +121,35 @@ jobs: |
106 | 121 | echo "name=${DIR_NAME}" >> "$GITHUB_OUTPUT" |
107 | 122 | echo "path=${{ env.WORK_DIR }}/${DIR_NAME}" >> "$GITHUB_OUTPUT" |
108 | 123 |
|
| 124 | + - name: Restore cached base app |
| 125 | + id: cache-base-app |
| 126 | + uses: actions/cache/restore@v4 |
| 127 | + with: |
| 128 | + path: ${{ steps.test-dir.outputs.path }} |
| 129 | + key: commerce-base-app-scss-standalone-${{ steps.angular-version.outputs.version }} |
| 130 | + |
109 | 131 | - name: Scaffold test app |
| 132 | + if: steps.cache-base-app.outputs.cache-hit != 'true' |
| 133 | + env: |
| 134 | + DIR_NAME: "${{ steps.test-dir.outputs.name }}" |
110 | 135 | run: | |
111 | 136 | rm -rf "${{ steps.test-dir.outputs.path }}" |
112 | 137 | mkdir -p "${{ env.WORK_DIR }}" |
| 138 | +
|
113 | 139 | cd "${{ env.WORK_DIR }}" |
114 | | - npx -y @angular/cli@${{ inputs.angular-version }} new "${{ steps.test-dir.outputs.name }}" \ |
| 140 | + npx -y @angular/cli@${{ steps.angular-version.outputs.version }} new "$DIR_NAME" \ |
115 | 141 | --style=scss \ |
116 | 142 | --skip-tests \ |
117 | 143 | --defaults |
118 | 144 |
|
119 | | - - name: Add @daffodil/commerce schematic |
| 145 | + - name: Cache base app |
| 146 | + if: steps.cache-base-app.outputs.cache-hit != 'true' |
| 147 | + uses: actions/cache/save@v4 |
| 148 | + with: |
| 149 | + path: ${{ steps.test-dir.outputs.path }} |
| 150 | + key: commerce-base-app-scss-standalone-${{ steps.angular-version.outputs.version }} |
| 151 | + |
| 152 | + - name: Add schematic |
120 | 153 | working-directory: ${{ steps.test-dir.outputs.path }} |
121 | 154 | run: | |
122 | 155 | CI=true npx ng add @daffodil/commerce@${{ env.TEST_VERSION }} \ |
|
0 commit comments