Skip to content

Commit

Permalink
Sync workflows with openlayers-base-packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeckem committed Sep 6, 2024
1 parent aa98c64 commit 355c384
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 56 deletions.
20 changes: 20 additions & 0 deletions .github/actions/install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Install
description: Install pnpm dependencies
runs:
using: "composite"
steps:
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"

- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile
19 changes: 2 additions & 17 deletions .github/workflows/audit-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,8 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install
uses: ./.github/actions/install

- name: Audit dependencies
run: pnpm audit
56 changes: 56 additions & 0 deletions .github/workflows/preview-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Preview PR
on:
pull_request:
types:
- opened
- closed
- reopened
- synchronize

jobs:
wait:
name: Wait for checks
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
# This is a separate file that simply waits for the other checks to complete because
# we don't want to run duplicate checks for pr + push events.
# Checks and builds run on all branches (on _push_) but this workflow runs only on PR events.
# If you know a smarter way, let us now.
- name: Wait for other checks to succeed
if: github.event.action != 'closed'
uses: lewagon/[email protected]
with:
ref: ${{ github.event.pull_request.head.sha }}
check-name: "Build samples and documentation"
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10

deploy:
name: Preview PR
runs-on: ubuntu-latest
concurrency: preview-${{ github.ref }}
timeout-minutes: 5
needs: wait
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Download latest build artifact
run: |
WORKFLOW_RUN=$(gh run list -c ${{ github.event.pull_request.head.sha }} -w "test-and-build.yml" -e push --json databaseId --limit 1 | jq .[0].databaseId -r)
echo "Latest workflow run: $WORKFLOW_RUN"
mkdir site && cd site;
echo "Downloading build artifact"
gh run download $WORKFLOW_RUN -n build
echo "Download successful:"
ls -alh
env:
GH_TOKEN: ${{ github.token }}

- name: Deploy PR Preview
uses: rossjrw/[email protected]
with:
source-dir: ./site/www/
64 changes: 40 additions & 24 deletions .github/workflows/test-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,42 @@ on:
push:
pull_request:
jobs:
test:
checks:
# Don't run for pull requests from this repository to avoid duplicate builds (push also triggers build).
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: "Test and Build"
name: "Run quality checks"
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: write
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install
uses: ./.github/actions/install

- name: Lint dependencies
run: pnpm lint-shared-versions

- name: Run tests
run: pnpm ci:test

build_site:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: "Build samples and documentation"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install

- name: Build samples
run: pnpm build

- name: Build packages
run: pnpm build-packages

- name: Build API documentation
if: github.ref == 'refs/heads/main'
run: pnpm build-docs

- name: Upload artifact
Expand All @@ -53,19 +49,39 @@ jobs:
path: dist/
retention-days: ${{ github.ref == 'refs/heads/main' && 7 || 1 }}

build_packages:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: "Build packages"
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install
uses: ./.github/actions/install

- name: Build packages
run: pnpm build-packages

call_version:
if: github.ref == 'refs/heads/main'
name: "Publish or create version PR"
uses: "./.github/workflows/version.yml"
needs: test
needs:
- checks
- build_packages
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

deploy:
if: github.ref == 'refs/heads/main'
name: "Deploy site"
runs-on: ubuntu-latest
timeout-minutes: 5
needs: test
needs:
- checks
- build_site
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
17 changes: 2 additions & 15 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,8 @@ jobs:
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: "https://registry.npmjs.org"
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install
uses: ./.github/actions/install

- name: Create Release Pull Request or Publish to npm
uses: changesets/action@v1
Expand Down

0 comments on commit 355c384

Please sign in to comment.