Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI action to sync published versions simple example to sandbox repository #10273

Merged
merged 8 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
branches:
- master
- next
tags:
- '*'
pull_request:

jobs:
Expand Down Expand Up @@ -57,6 +59,7 @@ jobs:

doc-check:
runs-on: ubuntu-latest
if: github.ref_type != 'tag'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -99,6 +102,7 @@ jobs:

e-commerce:
runs-on: ubuntu-latest
if: github.ref_type != 'tag'
needs: [typecheck]
steps:
- name: Checkout
Expand Down Expand Up @@ -133,6 +137,7 @@ jobs:

crm:
runs-on: ubuntu-latest
if: github.ref_type != 'tag'
needs: [typecheck]
steps:
- name: Checkout
Expand All @@ -157,7 +162,7 @@ jobs:
runs-on: ubuntu-latest
name: GreenFrame
needs: [e-commerce]
if: success() && github.ref == 'refs/heads/master'
if: success() && github.ref == 'refs/heads/master' && github.ref_type != 'tag'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: on the contrary, we could run the Greenframe analysis only when a new tag/version is released, as opposed to any commit on master which might be a little too often. Wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fzaninotto any opinion?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that we should only test greenframe when releasing a new version

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

steps:
# To use this repository's private action,
# you must check out the repository
Expand Down Expand Up @@ -208,3 +213,21 @@ jobs:
- name: Run the tests
working-directory: ./myadmin
run: npm run test

update-sandbox-repository:
runs-on: ubuntu-latest
# Only run on new tags that target a release (not latest nor next) and avoid alpha and beta tags
if: github.event_name == 'push' && github.ref_type == 'tag' && github.ref_name == 'refs/tags/v*' && !contains('beta', github.ref_name) && !contains('alpha', github.ref_name)
needs: [typecheck, simple-example-typecheck, unit-test, e2e-test]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: '16.x'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
node-version: '16.x'
node-version: '18.x'

To be consistent with other jobs of the workflow

- name: Update Sandbox Repository
env:
SSH_DEPLOY_KEY: ${{ secrets.SSH_SANDBOX_DEPLOY_KEY }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SSH_DEPLOY_KEY: ${{ secrets.SSH_SANDBOX_DEPLOY_KEY }}
SSH_SANDBOX_DEPLOY_KEY: ${{ secrets.SSH_SANDBOX_DEPLOY_KEY }}

To be consistent with the actual script

SANDBOX_REPOSITORY: ${{ secrets.SANDBOX_REPOSITORY }}
run: make update-sandbox
slax57 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,6 @@ storybook: ## Launch the storybook
build-storybook: ## Build the storybook
@echo "Building storybook..."
@yarn build-storybook

update-sandbox: ## Push the local version of the simple example to the sandbox repository
./update-demo.sh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
./update-demo.sh
./update-sandbox.sh

(there is no update-demo.sh)

34 changes: 34 additions & 0 deletions scripts/update-sandbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash

# Configure git
git config --global user.email "[email protected]"
git config --global user.name "React-Admin CI"

# Configure ssh keys
mkdir --parents "$HOME/.ssh"
DEPLOY_KEY_FILE="$HOME/.ssh/deploy_key"
echo "${SSH_SANDBOX_DEPLOY_KEY}" > "$DEPLOY_KEY_FILE"
chmod 600 "$DEPLOY_KEY_FILE"
SSH_KNOWN_HOSTS_FILE="$HOME/.ssh/known_hosts"
ssh-keyscan -H github.com > "$SSH_KNOWN_HOSTS_FILE"

# Override the default git ssh command so that it includes our ssh key
export GIT_SSH_COMMAND="ssh -i "$DEPLOY_KEY_FILE" -o UserKnownHostsFile=$SSH_KNOWN_HOSTS_FILE"

# Clone the demo repository inside a temporary directory
TEMPD=$(mktemp -d)
echo $TEMPD
(git clone ${SANDBOX_REPOSITORY} $TEMPD)

# Clean it up to ensure we don't keep deleted files
(rm -rf $TEMPD/src)
(rm -rf $TEMPD/assets)

# Copy the demo files into the temporary directory
(cp -r ./examples/simple/. $TEMPD)

# Update the demo repository
# Allow empty commits because even though we may have published new version of the enterprise packages,
# the demo code may not have changed. However we still want it to be redeployed and, as we don't keep its
# yarn.lock, it should use the new packages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the rationale, but I believe @fzaninotto was in favor of actually computing and committing the yarn.lock file, in order to reduce the sandbox startup time

(cd $TEMPD && git add -A && git commit --allow-empty -m "Update sandbox" && git push)
erwanMarmelab marked this conversation as resolved.
Show resolved Hide resolved
Loading