Skip to content

Commit

Permalink
Merge pull request #134 from aldbr/main_FEAT_improve-ci-tags
Browse files Browse the repository at this point in the history
feat(gha): improve ci
  • Loading branch information
fstagni authored Jun 24, 2024
2 parents ffe255c + db37351 commit 001be55
Show file tree
Hide file tree
Showing 13 changed files with 1,412 additions and 171 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"}
33 changes: 19 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
![Basic tests](https://github.com/DIRACGrid/diracx-web/actions/workflows/basic.yml/badge.svg?branch=main)
![Basic tests](https://github.com/DIRACGrid/diracx-web/actions/workflows/test.yml/badge.svg?branch=main)
![Basic tests](https://github.com/DIRACGrid/diracx-web/actions/workflows/containerised.yml/badge.svg?branch=main)
![Unit tests](https://github.com/DIRACGrid/diracx-web/actions/workflows/test.yml/badge.svg?branch=main)
![Integration tests](https://github.com/DIRACGrid/diracx-web/actions/workflows/integration-test.yml/badge.svg?branch=main)
![Deployment](https://github.com/DIRACGrid/diracx-web/actions/workflows/deployment.yml/badge.svg?branch=main)

# DiracX-Web Prototype
# DiracX-Web

## Getting started

This will allow you to run a demo setup.
_Requirements: docker, internet_

The code changes will be reflected in the demo.

Requirement: docker, internet
This will allow you to run a demo setup:

```bash
# Clone the diracx repository
git clone git@github.com:DIRACGrid/diracx.git
# Clone the diracx-chart repository
git clone git@github.com:DIRACGrid/diracx-charts.git

# Run the demo
diracx-charts/run_demo.sh
```

You can also start the demo setup in development mode - code changes will be reflected in the demo in real time:

```bash
# Clone the diracx-web repository
git clone git@github.com:DIRACGrid/diracx-web.git

# Clone the diracx-chart repository
git clone git@github.com:DIRACGrid/diracx-charts.git

# Run the demo
diracx-charts/run_demo.sh diracx/ diracx-web/
diracx-charts/run_demo.sh ./diracx-web
```

Open [http://localhost:8000](http://localhost:8000) with your browser to see the result.

## Contributing

- Want to report a bug?
Expand All @@ -46,13 +50,14 @@ Open [http://localhost:8000](http://localhost:8000) with your browser to see the

Unit tests can be started with:

```
```bash
npm test
```

End-to-end tests are launched through `cypress` such as:

```
```bash
# diracx-charts/run_demo.sh is running
npx cypress open --config baseUrl=$DIRACX_URL
```

Expand Down
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 001be55

Please sign in to comment.