Skip to content

Commit

Permalink
feat(gha): improve github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
aldbr committed May 16, 2024
1 parent 706c121 commit fd35826
Show file tree
Hide file tree
Showing 12 changed files with 1,393 additions and 157 deletions.
38 changes: 18 additions & 20 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
name: Basic checks

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]
pull_request:
branches: [main]
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
build:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web'
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: npm install
- uses: actions/setup-node@v4
with:
node-version: 'latest'
cache: 'npm'
- name: Install dependencies
run: npm ci

- name: Check formatting rules
run: npx prettier . --check

- name: Check code-quality rules
run: npm run lint

- name: Check typescript type validity
run: npm run ts-lint
- name: Check formatting rules
run: npx prettier . --check
- name: Check code-quality rules
run: npm run lint
- name: Check typescript type validity
run: npm run ts-lint

27 changes: 27 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Commit Lint

on: [push, pull_request]

jobs:
commitlint:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-node@v4
with:
node-version: 'latest'
cache: 'npm'
- name: Install dependencies
run: npm ci

- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose
31 changes: 0 additions & 31 deletions .github/workflows/containerised.yml

This file was deleted.

75 changes: 75 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Deployment

on: [push, pull_request]

jobs:
release-please:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.repository == 'DIRACGrid/diracx-web' }}
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v4
id: release
with:
token: ${{ secrets.GITHUB_TOKEN }}
target-branch: ${{ github.ref_name }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

build-deploy-dev-image:
runs-on: ubuntu-latest
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 }}

- name: Build Docker image (dev)
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' && github.repository == 'DIRACGrid/diracx-web' && github.ref_name == 'main' }}
tags: ghcr.io/diracgrid/diracx-web/static:dev
platforms: linux/amd64,linux/arm64

build-deploy-release-image:
runs-on: ubuntu-latest
needs: release-please
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 }}

- name: Build Docker image
if: ${{ needs.release-please.outputs.release_created == 'true' }}
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/diracgrid/diracx-web/static:${{ needs.release-please.outputs.tag_name }}
platforms: linux/amd64,linux/arm64
94 changes: 46 additions & 48 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
name: Integration Tests

on:
push:
branches: [main]
pull_request:
branches: [main]
on: [push, pull_request]

defaults:
run:
shell: bash -el {0}
run:
shell: bash -el {0}

jobs:
run-demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Clone source
run: |
cd ..
git clone https://github.com/DIRACGrid/diracx-charts.git
- name: Start demo
run: |
cd ..
diracx-charts/run_demo.sh --exit-when-done diracx-web/
- 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
- 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-demo:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web'
steps:
- uses: actions/checkout@v4

- name: Start Cypress
uses: cypress-io/github-action@v6
with:
browser: chrome
config: baseUrl=${{ env.DIRACX_URL }}
- name: Clone source
run: |
cd ..
git clone https://github.com/DIRACGrid/diracx-charts.git
- name: Start demo
run: |
cd ..
diracx-charts/run_demo.sh --exit-when-done diracx-web/
- 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
- 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

- name: Start Cypress
uses: cypress-io/github-action@v6
with:
browser: chrome
config: baseUrl=${{ env.DIRACX_URL }}
28 changes: 14 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Tests

on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [main]
pull_request:
branches: [main]
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
build:
runs-on: ubuntu-latest
if: github.event_name != 'push' || github.repository == 'DIRACGrid/diracx-web'
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: npm install
- uses: actions/setup-node@v4
with:
node-version: 'latest'
cache: 'npm'
- name: Install dependencies
run: npm ci

- name: Trigger tests
run: npm run test
- name: Trigger tests
run: npm run test
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ dist
public
.github
jest.config.mjs
release-please-config.json
.release-please-manifest.json
CHANGELOG.md
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{".": "0.1.0-a0"}
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
Loading

0 comments on commit fd35826

Please sign in to comment.