mirror of https://github.com/jacekkow/keycloak-protocol-cas

Jacek Kowalski
2020-05-10 4da0d94b96e662b8dffe281d0a2de812f11cda71
commit | author | age
fd0b0f 1 on:
JK 2   pull_request:
3
4 name: Test
5
6 jobs:
7   build:
8     name: Build
9     runs-on: ubuntu-latest
10     steps:
11       - id: checkout
12         name: Checkout code
13         uses: actions/checkout@v2
14
15       - name: Install Java and Maven
16         uses: actions/setup-java@v1
17         with:
18           java-version: 8
19
20       - id: vars
21         name: Get project variables
22         run: |
23           echo -n "::set-output name=keycloakVersion::"
4da0d9 24           mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$'
fd0b0f 25           echo -n "::set-output name=artifactId::"
4da0d9 26           mvn -q help:evaluate -Dexpression=project.artifactId -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$'
fd0b0f 27           echo -n "::set-output name=projectName::"
4da0d9 28           mvn -q help:evaluate -Dexpression=project.name -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z :,.-]+$'
fd0b0f 29           echo -n "::set-output name=projectVersion::"
4da0d9 30           mvn -q help:evaluate -Dexpression=project.version -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$'
fd0b0f 31
JK 32       - name: Build project
33         run: |
34           mvn -B test package
35
36       - name: Upload artifact
37         uses: actions/upload-artifact@v1
38         with:
39           name: jar
40           path: target/${{ steps.vars.outputs.artifactId }}-${{ steps.vars.outputs.projectVersion }}.jar
41
42     outputs:
43       artifact_id: ${{ steps.vars.outputs.artifactId }}
44       keycloak_version: ${{ steps.vars.outputs.keycloakVersion }}
45       project_name: ${{ steps.vars.outputs.projectName }}
46       project_version: ${{ steps.vars.outputs.projectVersion }}
47
48   test:
49     name: Test
50     runs-on: ubuntu-latest
51     needs: build
52     services:
53       keycloak:
54         image: quay.io/keycloak/keycloak:${{ needs.build.outputs.keycloak_version }}
55         env:
56           KEYCLOAK_USER: admin
57           KEYCLOAK_PASSWORD: admin
58         ports:
59           - 8080:8080
60         volumes:
61           - '${{ github.workspace }}:/workspace'
62     steps:
63       - id: checkout
64         name: Checkout code
65         uses: actions/checkout@v2
66
67       - id: download_artifact
68         name: Download artifact
69         uses: actions/download-artifact@v1
70         with:
71           name: jar
72
73       - id: deploy
74         name: Deploy artifact
75         run: |
76           CONTAINER="${{ job.services.keycloak.id }}"
77           NAME="${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar"
78           FILE="/opt/jboss/keycloak/standalone/deployments/${NAME}"
79           docker cp "jar/${NAME}" "${CONTAINER}:/tmp/"
80           docker exec -i "${CONTAINER}" /bin/bash <<EOF
81             cp "/tmp/${NAME}" "${FILE}"
82             for i in {1..60}; do
83               echo -n .
84               [ -f "${FILE}.deployed" ] && echo && echo "Deployment succeeded!" && exit 0
85               [ -f "${FILE}.failed" ] && echo && echo "Deployment failed!" && exit 1
86               sleep 1
87             done
88             echo && echo "Deployment timeout!" && exit 1
89           EOF
90
91       - id: configure_keycloak
92         name: Configure Keycloak
93         run: |
94           CONTAINER="${{ job.services.keycloak.id }}"
95           docker exec -i "${CONTAINER}" /bin/bash <<EOF
96             /opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin
97             /opt/jboss/keycloak/bin/kcadm.sh create clients -r master -s clientId=test -s protocol=cas -s enabled=true -s publicClient=true \
98               -s 'redirectUris=["http://localhost/*"]' -s baseUrl=http://localhost -s adminUrl=http://localhost
99             /opt/jboss/keycloak/bin/kcadm.sh get serverinfo -r master --fields "providers(login-protocol(providers(cas)))" | grep cas
100           EOF
101
102       - id: run_tests
103         name: Run tests
104         run: |
105           integrationTest/suite.sh