This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
Rebase zalando/zally onto SBB/zally #16
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: Zally Pull Request Builds | |
on: | |
push: | |
branches: | |
- main | |
- master | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
- '[0-9]+.[0-9]+.[0-9]+-*' | |
pull_request: | |
branches: | |
- main | |
- master | |
jobs: | |
build-zally: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Cache Gradle packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Build Zally Server | |
run: | | |
cd server/ | |
chmod +x gradlew | |
./gradlew --console=plain build | |
- uses: codecov/codecov-action@v1 | |
with: | |
files: ./server/zally-server/build/reports/jacoco/test/jacocoTestReport.xml,./server/zally-ruleset-zally/build//reports/jacoco/test/jacocoTestReport.xml,./server/zally-ruleset-sbb/build/reports/jacoco/test/jacocoTestReport.xml,./server/zally-core/build/reports/jacoco/test/jacocoTestReport.xml,./server/zally-rule-api/build/reports/jacoco/test/jacocoTestReport.xml | |
- name: Cleanup Gradle Cache | |
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. | |
# Restoring these files from a GitHub Actions cache might cause problems for future builds. | |
run: | | |
rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
rm -f ~/.gradle/caches/modules-2/gc.properties | |
- name: Build Docker Image | |
run: | | |
docker build \ | |
-t schweizerischebundesbahnen/zally-server:latest \ | |
./server | |
- name: Login to Docker Repository | |
uses: azure/docker-login@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
if: github.ref_name == 'master' || github.ref_name == 'main' || startsWith(github.ref, 'refs/tags') | |
- name: Tag latest | |
if: github.ref_name == 'master' || github.ref_name == 'main' | |
run: docker image tag schweizerischebundesbahnen/zally-server schweizerischebundesbahnen/zally-server:latest | |
- name: Parse release version from git tag | |
if: startsWith(github.ref, 'refs/tags') | |
id: docker_release_version | |
run: echo ::set-output name=docker_release_version::${GITHUB_REF/refs\/tags\//} | |
- name: Tag version | |
if: startsWith(github.ref, 'refs/tags') | |
run: docker image tag schweizerischebundesbahnen/zally-server schweizerischebundesbahnen/zally-server:${{ steps.docker_release_version.outputs.docker_release_version }} | |
- name: Push Docker Image | |
run: docker push schweizerischebundesbahnen/zally-server --all-tags | |
if: github.ref_name == 'master' || github.ref_name == 'main' || startsWith(github.ref, 'refs/tags') | |
build-cli: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: '1.16' | |
- run: go version | |
- name: Run Zally server | |
run: | | |
cd server/ | |
chmod +x gradlew | |
./gradlew --console=plain bootRun > /dev/null & | |
echo $! > /tmp/zally_server.pid | |
cd .. | |
while ! echo "GET / HTTP/1.0\n" | nc localhost 8000; do sleep 1; done | |
- name: Build & Run CLI tests | |
run: | | |
cd cli/zally | |
./test.sh | |
./test.sh integration | |
go build | |
cd ../.. | |
- uses: codecov/codecov-action@v1 | |
with: | |
files: ./cli/zally/coverage.txt | |
- name: Release CLI with GoReleaser | |
uses: goreleaser/goreleaser-action@v2 | |
if: startsWith(github.ref, 'refs/tags') | |
with: | |
version: latest | |
args: release --rm-dist | |
workdir: . | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build-web-ui: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: "18.14.2" | |
- name: Configure yarn | |
run: yarn install -q | |
- name: Build & Test CLI | |
run: | | |
cd web-ui | |
yarn add zally-web-ui | |
yarn test | |
yarn build | |
- uses: codecov/codecov-action@v1 | |
with: | |
files: ./web-ui/target/coverage/lcov.info | |
- name: Build Docker Image | |
run: | | |
docker build \ | |
-t schweizerischebundesbahnen/zally-web-ui:latest \ | |
./web-ui | |
- name: Login to Docker Repository | |
uses: azure/docker-login@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
if: github.ref_name == 'master' || github.ref_name == 'main' || startsWith(github.ref, 'refs/tags') | |
- name: Tag latest | |
if: github.ref_name == 'master' || github.ref_name == 'main' | |
run: docker image tag schweizerischebundesbahnen/zally-web-ui schweizerischebundesbahnen/zally-web-ui:latest | |
- name: Parse release version from git tag | |
if: startsWith(github.ref, 'refs/tags') | |
id: docker_release_version | |
run: echo ::set-output name=docker_release_version::${GITHUB_REF/refs\/tags\//} | |
- name: Tag version | |
if: startsWith(github.ref, 'refs/tags') | |
run: docker image tag schweizerischebundesbahnen/zally-web-ui schweizerischebundesbahnen/zally-web-ui:${{ steps.docker_release_version.outputs.docker_release_version }} | |
- name: Push Docker Image | |
run: docker push schweizerischebundesbahnen/zally-web-ui --all-tags | |
if: github.ref_name == 'master' || github.ref_name == 'main' || startsWith(github.ref, 'refs/tags') |