feat: extension management #41
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gubbins extension tests | |
on: | |
push: | |
paths-ignore: | |
- 'packages/diracx-web/**' | |
branches-ignore: | |
- dependabot/** | |
- release-please-** | |
pull_request: | |
branches-ignore: | |
- release-please-** | |
jobs: | |
# Run lint and type checks | |
run-lint: | |
runs-on: ubuntu-latest | |
# Run the tests only if It's a PR or if the repo is DIRACGrid/diracx-web | |
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' | |
steps: | |
# Checkout the new source code | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
# ========================================================================# | |
# WARNING: In your CI/CD pipeline, you should remove the following step # | |
# ------------------------------------------------------------------------# | |
- name: Build Library | |
run: npm run build:diracx-web-components | |
# ------------------------------------------------------------------------# | |
# ========================================================================# | |
- name: Check code-quality rules | |
run: npm --prefix packages/extensions run lint | |
- name: Check typescript type validity | |
run: npm --prefix packages/extensions run ts-lint | |
# ============================================================================# | |
# WARNING: In your CI/CD pipeline, you should remove the following job # | |
# ----------------------------------------------------------------------------# | |
prepare-gubbins-as-a-standalone: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build diracx-web-components | |
working-directory: packages/diracx-web-components | |
run: | | |
npm pack | |
- name: Where the magic happens (Move extensions to a temporary directory) | |
run: | | |
# Move the library package to the extensions directory | |
mv packages/diracx-web-components/*.tgz packages/extensions/diracx-web-components.tgz | |
# Move the extensions to the temporary directory | |
mv packages/extensions /tmp/extensions | |
# Update the package.json to point to the local diracx-web-components | |
jq '.dependencies["@dirac-grid/diracx-web-components"] = "file:/tmp/extensions/diracx-web-components.tgz"' /tmp/extensions/package.json > /tmp/extensions/package.temp.json | |
mv /tmp/extensions/package.temp.json /tmp/extensions/package.json | |
# Update the package.json to point to the correct postinstall script | |
jq '.scripts.postinstall = "node ./node_modules/@axa-fr/react-oidc/bin/copy-service-worker-files.mjs public"' /tmp/extensions/package.json > /tmp/extensions/package.temp.json | |
mv /tmp/extensions/package.temp.json /tmp/extensions/package.json | |
- name: Install extensions dependencies | |
working-directory: /tmp/extensions | |
run: npm install | |
- name: Compress the extensions directory | |
run: tar -czf /tmp/extensions.tar.gz -C /tmp extensions | |
- name: Upload the extensions directory | |
uses: actions/upload-artifact@v4 | |
with: | |
name: /tmp/extensions.tar.gz | |
# ----------------------------------------------------------------------------# | |
# In the following jobs, you should: # | |
# - Replace /tmp/extensions with the path to your extension source code # | |
# - Remove the `needs: prepare-gubbins-as-a-standalone` line # | |
# ============================================================================# | |
# Build the extension image | |
build-gubbins-dev-image: | |
runs-on: ubuntu-latest | |
needs: prepare-gubbins-as-a-standalone | |
if: ${{ github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# ========================================================================# | |
# WARNING: In your CI/CD pipeline, you should remove the following steps # | |
# ------------------------------------------------------------------------# | |
- name: Download the extensions directory | |
uses: actions/download-artifact@v4 | |
with: | |
name: /tmp/extensions.tar.gz | |
- name: Extract the extensions directory | |
run: tar -xzf /tmp/extensions.tar.gz -C /tmp | |
# ------------------------------------------------------------------------# | |
# ========================================================================# | |
- name: Build Docker image (extension example) | |
uses: docker/build-push-action@v6 | |
with: | |
context: /tmp/extensions | |
push: false | |
tags: ghcr.io/diracgrid/diracx-web/gubbins:dev | |
platforms: linux/amd64,linux/arm64 | |
# Run the demo with the extension source code | |
run-demo: | |
runs-on: ubuntu-latest | |
needs: prepare-gubbins-as-a-standalone | |
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web' | |
steps: | |
# Checkout the new source code | |
- uses: actions/checkout@v4 | |
# Clone diracx-charts | |
- name: Clone source | |
run: | | |
cd .. | |
git clone https://github.com/aldbr/diracx-charts.git | |
# ========================================================================# | |
# WARNING: In your CI/CD pipeline, you should remove the following steps # | |
# ------------------------------------------------------------------------# | |
- name: Download the extensions directory | |
uses: actions/download-artifact@v4 | |
with: | |
name: /tmp/extensions.tar.gz | |
- name: Extract the extensions directory | |
run: tar -xzf /tmp/extensions.tar.gz -C /tmp | |
# ------------------------------------------------------------------------# | |
# ========================================================================# | |
# Runs the demo with the extension source code | |
- name: Start demo | |
run: | | |
diracx-charts/run_demo.sh --exit-when-done /tmp/extensions | |
# Prints some debugging information in case something goes wrong | |
- name: Debugging information | |
run: | | |
cd ../diracx-charts | |
export KUBECONFIG=$PWD/.demo/kube.conf | |
.demo/kubectl get pods | |
for pod_name in $(.demo/kubectl get pods -o json | jq -r '.items[] | .metadata.name' | grep -vE '(dex|minio|mysql|rabbitmq|opensearch)'); do | |
echo "${pod_name}" | |
.demo/kubectl describe pod/"${pod_name}" || true | |
for container_name in $(.demo/kubectl get pods $pod_name -o jsonpath='{.spec.initContainers[*].name} {.spec.containers[*].name}'); do | |
echo $pod_name $container_name | |
.demo/kubectl logs "${pod_name}" -c "${container_name}" || true | |
done | |
done | |
- name: Check for success | |
run: | | |
cd ../diracx-charts | |
if [ ! -f ".demo/.success" ]; then | |
echo "Demo failed" | |
cat ".demo/.failed" | |
exit 1 | |
fi | |
# Find the URL to be tested and put it in the github environment | |
- name: Set DIRACX_URL | |
run: echo "DIRACX_URL=https://$(ifconfig | grep 'inet ' | awk '{ print $2 }' | grep -v '^127' | head -n 1 | cut -d '/' -f 1).nip.io:8000" >> $GITHUB_ENV | |
# Run e2e tests with Cypress | |
- name: Start Cypress | |
uses: cypress-io/github-action@v6 | |
with: | |
browser: chrome | |
config: baseUrl=${{ env.DIRACX_URL }} | |
project: /tmp/extensions |