Skip to content

Commit

Permalink
feat: run ci/cd only for packages with changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszherba committed Dec 16, 2024
1 parent 54d0187 commit 7ec97be
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 23 deletions.
45 changes: 45 additions & 0 deletions .github/init/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Init repository
description: Installs all the packages and initializes environment variables
inputs:
auth_token:
description: NPM Registry _authToken
type: string
required: true
node_version:
description: Node versions to test
type: string
required: false
default: "18.20.2"

runs:
using: composite
steps:
- name: Use Node.js ${{ inputs.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version }}
cache: yarn

- name: Set enterprise registry
shell: bash
run: |
npm config set @vsf-enterprise:registry https://registrynpm.storefrontcloud.io
npm config set //registrynpm.storefrontcloud.io/:_authToken ${{ inputs.auth_token }}
- name: Load yarn cache
uses: actions/cache@v4
with:
key: yarn-cache
path: .yarn

- name: Install dependencies
shell: bash
run: yarn install --frozen-lockfile --cache-folder .yarn

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
37 changes: 14 additions & 23 deletions .github/workflows/ci-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ on:
required: false
default: false


jobs:
run-ci:
name: Run CI
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ["18.20.2"]
permissions:
contents: read
id-token: write
timeout-minutes: 120
timeout-minutes: 15
if: github.event.pull_request.draft == false
steps:
- name: Expose github environment as shell variables
env:
Expand All @@ -33,39 +36,27 @@ jobs:
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
to_envs() { jq -r "to_entries[] | \"\(.key)<<$EOF\n\(.value)\n$EOF\n\""; }
echo "$SECRETS_CONTEXT" | to_envs >> $GITHUB_ENV
- uses: actions/checkout@v4

- uses: actions/setup-node@v4

- name: Install dependencies
uses: ./.github/actions/init
with:
node-version-file: '.node-version'
registry-url: ${{ inputs.enterprise && 'https://registrynpm.storefrontcloud.io' || '' }}
cache: yarn

- run: yarn install --frozen-lockfile
env:
NODE_AUTH_TOKEN: ${{ secrets.VERDACCIO_AUTH_TOKEN }}
HUSKY: 0
node_version: ${{ matrix.node-version }}
auth_token: ${{ secrets.VERDACCIO_AUTH_TOKEN }}

- name: Detect circular dependencies 🔄
uses: vuestorefront/vue-storefront/actions/circular-dependencies@main
with:
filesPath: 'packages/**/*.{ts,vue}'
filesPath: "packages/**/*.{ts,vue}"

- name: Check licenses 🧪
uses: vuestorefront/vue-storefront/actions/check-licenses@main
with:
projectPath: ${{ github.workspace }}

- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- run: yarn ci
- name: Run the pipeline
run: ./node_modules/.bin/turbo run build lint test:unit test:integration --cache-dir=.turbo --filter=\[${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}\]

- name: Upload test coverage
uses: actions/upload-artifact@v4
Expand Down

0 comments on commit 7ec97be

Please sign in to comment.