speedup ci #52
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: build | |
on: | |
push | |
env: | |
TEST_TAG: user/cmsjson:test | |
LATEST_TAG: ghcr.io/guyzsarun/xrootd-cmsjson:latest | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v2 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
tags: ${{ env.TEST_TAG }} | |
load: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
test-json: | |
name: Test LFN Conversion | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v2 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Unit test | |
run: | | |
docker load --input /tmp/myimage.tar | |
docker run --rm ${{ env.TEST_TAG }} python3 -m pytest -v | |
test-rpm: | |
name: Test RPM package | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v2 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Unit test | |
run: | | |
docker run --rm ${{ env.TEST_TAG }} bash -c ' | |
mkdir -p /root/rpmbuild/SOURCES/ && | |
tar -cvf /root/rpmbuild/SOURCES/xrootd-cmsjson.tar.gz . && | |
rpmbuild -bb spec/xrootd-cmsjson.spec | |
' | |
push-registry: | |
name: Push to Registry | |
runs-on: ubuntu-latest | |
needs: [test-json,test-rpm] | |
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/release' | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v2 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Build Docker image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
file: docker/Dockerfile | |
load: true | |
tags: ${{ env.TEST_TAG }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Tag image | |
run: | | |
docker load --input /tmp/myimage.tar | |
docker tag ${{ env.TEST_TAG }} ${{ env.LATEST_TAG }} | |
- name: Push to registry | |
run: docker push ${{ env.LATEST_TAG }} | |
build_tarball: | |
name: Build source archive | |
needs: [test-json,test-rpm] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Create source archive | |
run: tar -cvf xrootd-cmsjson.tar.gz * | |
- name: Upload source archive as artifact | |
if: always() && github.ref == 'refs/heads/master' | |
uses: actions/upload-artifact@v3 | |
with: | |
name: xrootd-cmsjson.tar.gz | |
path: xrootd-cmsjson.tar.gz |