2022-06-24 07:21:36 +00:00
|
|
|
on: push
|
|
|
|
name: CI
|
|
|
|
jobs:
|
|
|
|
npm-tests:
|
|
|
|
env:
|
|
|
|
CHROME_BIN: /usr/bin/chromium
|
|
|
|
runs-on: [self-hosted]
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2022-06-28 11:53:07 +00:00
|
|
|
node: ['14', '16', '18']
|
2022-06-24 07:21:36 +00:00
|
|
|
name: Node Tests
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: ${{matrix.node}}
|
|
|
|
- run: npm install
|
|
|
|
- name: test
|
|
|
|
continue-on-error: true
|
|
|
|
id: test
|
|
|
|
run: npm test
|
|
|
|
- name: retry
|
|
|
|
continue-on-error: true
|
|
|
|
id: retry1
|
|
|
|
if: steps.test.outcome=='failure'
|
|
|
|
run: npm test
|
|
|
|
- name: set the status
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
if ${{ steps.test.outcome=='success' || steps.retry1.outcome=='success' }}; then
|
|
|
|
echo "Tests Passed"
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
docker-tests:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
timeout-minutes: 5
|
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Docker test
|
|
|
|
run: |
|
|
|
|
wget https://github.com/tkp1n/chromium-ci/raw/41510dc154c4184f7e09461ba76f86f61c460070/seccomp/chromium.json
|
|
|
|
docker build -t prom-act-test .
|
2022-06-28 12:21:47 +00:00
|
|
|
container_name=$(docker run --security-opt seccomp=chromium.json --detach prom-act-test)
|
|
|
|
echo $container_name
|
|
|
|
docker inspect $container_name
|
|
|
|
docker ps --no-trunc
|
|
|
|
until [ "`docker inspect -f {{.State.Health.Status}} $container_name`" == "healthy" ]; do
|
|
|
|
sleep 10;
|
2022-06-24 07:21:36 +00:00
|
|
|
echo "Waiting for container to be healthy"
|
2022-06-28 12:21:47 +00:00
|
|
|
docker inspect -f {{.State.Health}} $container_name
|
|
|
|
docker logs $container_name
|
2022-06-24 07:21:36 +00:00
|
|
|
done;
|
2022-06-28 12:21:47 +00:00
|
|
|
docker inspect $container_name
|
2022-06-28 11:53:07 +00:00
|
|
|
sleep 5
|
2022-06-24 07:21:36 +00:00
|
|
|
# Show usage
|
2022-06-28 12:21:47 +00:00
|
|
|
docker exec $container_name wget -q -O- localhost:3000/metrics | grep act_fup
|
2022-06-24 07:21:36 +00:00
|
|
|
# Check logs
|
2022-06-28 12:21:47 +00:00
|
|
|
docker logs $container_name
|
2022-06-24 07:21:36 +00:00
|
|
|
# Stop and kill the test container
|
2022-06-28 12:21:47 +00:00
|
|
|
docker stop $container_name && docker rm $container_name && docker rmi prom-act-test
|
2022-06-24 07:21:36 +00:00
|
|
|
publish:
|
|
|
|
needs: [npm-tests, docker-tests]
|
|
|
|
runs-on: [self-hosted]
|
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Login to GitHub Container Registry
|
|
|
|
uses: docker/login-action@v2
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Push to GitHub Container Registry
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
if: ${{github.ref_name != 'master'}}
|
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
tags: ghcr.io/${{ github.repository }}:${{github.ref_name}}
|
|
|
|
- name: Push to GitHub Container Registry (latest)
|
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
if: ${{github.ref_name == 'master'}}
|
|
|
|
with:
|
|
|
|
push: true
|
|
|
|
tags: ghcr.io/${{ github.repository }}:latest
|