diff --git a/.github/workflows/build-push-tests.yml b/.github/workflows/build-push-tests.yml new file mode 100644 index 000000000..5b4ceda75 --- /dev/null +++ b/.github/workflows/build-push-tests.yml @@ -0,0 +1,169 @@ +--- +name: build, push to registry and tests + +on: + push: + branches-ignore: + - 'development/**' + +jobs: + build: + runs-on: ubuntu-20.04 + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v2.3.5 + + - uses: actions/setup-node@v2.4.1 + with: + node-version: '16' + cache: 'npm' + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to Scality Registry + uses: docker/login-action@v2 + with: + registry: registry.scality.com + username: ${{ secrets.REGISTRY_LOGIN }} + password: ${{ secrets.REGISTRY_PASSWORD}} + + - name: install dependencies + run: npm config set unsafe-perm true && npm ci + + - name: build assets + run: npm run build + + - name: Build and push zenko ui + uses: docker/build-push-action@v2.7.0 + with: + push: true + context: . + tags: | + ghcr.io/${{ github.repository }}/zenko-ui:${{ github.sha }} + registry.scality.com/zenko-ui-dev/zenko-ui:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Build and push keycloak + uses: docker/build-push-action@v2.7.0 + with: + push: true + context: .github/docker/keycloakconfig + tags: ghcr.io/${{ github.repository }}/ci-keycloak:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max + + tests: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2.3.5 + - uses: actions/setup-node@v2.4.1 + with: + node-version: '16' + cache: 'npm' + - name: install dependencies + run: npm config set unsafe-perm true && npm ci + - name: run eslint test + run: npm run test:lint + - name: run test suite + run: npm run test:coverage + - name: code coverage + uses: codecov/codecov-action@v2.1.0 + + end2end: + needs: [build] + runs-on: ubuntu-20.04 + permissions: + contents: read + packages: write + env: + KEYCLOAK_ROOT: 'http://127.0.0.1:8080' + KEYCLOAK_REALM: 'myrealm' + KEYCLOAK_CLIENT_ID: 'myclient' + KEYCLOAK_USERNAME: 'bartsimpson' + KEYCLOAK_PASSWORD: '123' + KEYCLOAK_USER_FIRSTNAME: 'Bart' + KEYCLOAK_USER_LASTNAME: 'Simpson' + services: + keycloak: + image: ghcr.io/${{ github.repository }}/ci-keycloak:${{ github.sha }} + credentials: + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + ports: + - 8080:8080 + env: + # Couldn't find a way to not duplicate those variables + KEYCLOAK_ROOT: 'http://127.0.0.1:8080' + KEYCLOAK_REALM: 'myrealm' + KEYCLOAK_CLIENT_ID: 'myclient' + KEYCLOAK_USERNAME: 'bartsimpson' + KEYCLOAK_PASSWORD: '123' + KEYCLOAK_USER_FIRSTNAME: 'Bart' + KEYCLOAK_USER_LASTNAME: 'Simpson' + shell-ui: + image: registry.scality.com/metalk8s/shell-ui:v2.10.3 + ports: + - 8082:80 + steps: + - uses: actions/checkout@v2.3.5 + + - uses: actions/setup-node@v2.4.1 + with: + node-version: '16' + cache: 'npm' + - name: install dependencies + run: npm config set unsafe-perm true && npm ci + + - name: Login to GitHub Registry + uses: docker/login-action@v1.10.0 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + # Can't run Zenko UI as service as we're unable to attach + # volumes that are located inside the repository + - name: Run Zenko UI + run: > + docker run -d -p 8383:8383 + -v $(pwd)/.github/configs/ui-test-config-shell.json:/usr/share/nginx/html/config-shell.json + -v $(pwd)/.github/configs/ui-test-config.json:/usr/share/nginx/html/config.json + -v $(pwd)/conf/zenko-ui-nginx.conf:/etc/nginx/conf.d/default.conf + ghcr.io/${{ github.repository }}/zenko-ui:${{ github.sha }} + + - name: Wait for all services to start + run: | + bash wait_for_local_port.bash 8082 40 + bash wait_for_local_port.bash 8080 40 + bash wait_for_local_port.bash 8383 40 + + - name: Run end-to-end tests + run: npm run cypress:run + env: + CYPRESS_KEYCLOAK_USER_FULLNAME: '${{ env.KEYCLOAK_USER_FIRSTNAME }} ${{ env.KEYCLOAK_USER_LASTNAME }}' + CYPRESS_KEYCLOAK_USERNAME: '${{ env.KEYCLOAK_USERNAME }}' + CYPRESS_KEYCLOAK_PASSWORD: '${{ env.KEYCLOAK_PASSWORD }}' + CYPRESS_KEYCLOAK_ROOT: '${{ env.KEYCLOAK_ROOT }}' + CYPRESS_KEYCLOAK_CLIENT_ID: '${{ env.KEYCLOAK_CLIENT_ID }}' + CYPRESS_KEYCLOAK_REALM: '${{ env.KEYCLOAK_REALM }}' + + - name: code coverage + uses: codecov/codecov-action@v2.1.0 + + - name: Dump container logs + run: | + docker logs ${{ job.services.keycloak.id }} + docker logs ${{ job.services.shell-ui.id }} + if: always() diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 4422bf288..c8ea69538 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,55 +2,26 @@ name: release on: - workflow_dispatch: - inputs: - tag: - description: 'Tag to be released' - required: true + release: + types: [published] jobs: - release: - runs-on: ubuntu-20.04 + retag-docker-image: + runs-on: ubuntu-latest + secrets: inherit steps: - - name: Checkout - uses: actions/checkout@v2.3.5 - with: - ref: ${{ inputs.tag }} - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.6.0 + uses: docker/setup-buildx-action@v2 - name: Login to Registry - uses: docker/login-action@v1.10.0 + uses: docker/login-action@v2 with: registry: registry.scality.com username: ${{ secrets.REGISTRY_LOGIN }} password: ${{ secrets.REGISTRY_PASSWORD }} - - - uses: actions/setup-node@v2.4.1 - with: - node-version: '16' - cache: 'npm' - - - name: install dependencies - run: npm config set unsafe-perm true && npm ci - - - name: build assets - run: npm run build - - - name: Build and push - uses: docker/build-push-action@v2.7.0 - with: - context: . - push: true - tags: "registry.scality.com/zenko-ui/zenko-ui:${{ github.event.inputs.tag }}" - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Create Release - uses: softprops/action-gh-release@v0.1.13 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ github.event.inputs.tag }} - release_name: Release ${{ github.event.inputs.tag }} + - run: | + echo "$GITHUB_SHA" + echo "$GITHUB_REF" + docker pull registry.scality.com/zenko-ui-dev/zenko-ui:$GITHUB_SHA + docker tag registry.scality.com/zenko-ui-dev/zenko-ui:$GITHUB_SHA registry.scality.com/zenko-ui/zenko-ui:$GITHUB_REF + docker push registry.scality.com/zenko-ui/zenko-ui:$GITHUB_REF diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index e2a51ce01..000000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,169 +0,0 @@ ---- -name: tests - -on: - push: - branches-ignore: - - 'development/**' - -jobs: - build: - runs-on: ubuntu-20.04 - permissions: - contents: read - packages: write - steps: - - name: Checkout - uses: actions/checkout@v2.3.5 - - - uses: actions/setup-node@v2.4.1 - with: - node-version: '16' - cache: 'npm' - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.6.0 - - - name: Login to GitHub Registry - uses: docker/login-action@v1.10.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Login to Scality Registry - uses: docker/login-action@v1.10.0 - with: - registry: registry.scality.com - username: ${{ secrets.REGISTRY_LOGIN }} - password: ${{ secrets.REGISTRY_PASSWORD}} - - - name: install dependencies - run: npm config set unsafe-perm true && npm ci - - - name: build assets - run: npm run build - - - name: Build and push zenko ui - uses: docker/build-push-action@v2.7.0 - with: - push: true - context: . - tags: | - ghcr.io/${{ github.repository }}/zenko-ui:${{ github.sha }} - registry.scality.com/zenko-ui-dev/zenko-ui:${{ github.sha }} - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Build and push keycloak - uses: docker/build-push-action@v2.7.0 - with: - push: true - context: .github/docker/keycloakconfig - tags: ghcr.io/${{ github.repository }}/ci-keycloak:${{ github.sha }} - cache-from: type=gha - cache-to: type=gha,mode=max - - tests: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2.3.5 - - uses: actions/setup-node@v2.4.1 - with: - node-version: '16' - cache: 'npm' - - name: install dependencies - run: npm config set unsafe-perm true && npm ci - - name: run eslint test - run: npm run test:lint - - name: run test suite - run: npm run test:coverage - - name: code coverage - uses: codecov/codecov-action@v2.1.0 - - end2end: - needs: [build] - runs-on: ubuntu-20.04 - permissions: - contents: read - packages: write - env: - KEYCLOAK_ROOT: "http://127.0.0.1:8080" - KEYCLOAK_REALM: "myrealm" - KEYCLOAK_CLIENT_ID: "myclient" - KEYCLOAK_USERNAME: "bartsimpson" - KEYCLOAK_PASSWORD: "123" - KEYCLOAK_USER_FIRSTNAME: "Bart" - KEYCLOAK_USER_LASTNAME: "Simpson" - services: - keycloak: - image: ghcr.io/${{ github.repository }}/ci-keycloak:${{ github.sha }} - credentials: - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - ports: - - 8080:8080 - env: - # Couldn't find a way to not duplicate those variables - KEYCLOAK_ROOT: "http://127.0.0.1:8080" - KEYCLOAK_REALM: "myrealm" - KEYCLOAK_CLIENT_ID: "myclient" - KEYCLOAK_USERNAME: "bartsimpson" - KEYCLOAK_PASSWORD: "123" - KEYCLOAK_USER_FIRSTNAME: "Bart" - KEYCLOAK_USER_LASTNAME: "Simpson" - shell-ui: - image: registry.scality.com/metalk8s/shell-ui:v2.10.3 - ports: - - 8082:80 - steps: - - uses: actions/checkout@v2.3.5 - - - uses: actions/setup-node@v2.4.1 - with: - node-version: '16' - cache: 'npm' - - name: install dependencies - run: npm config set unsafe-perm true && npm ci - - - name: Login to GitHub Registry - uses: docker/login-action@v1.10.0 - with: - registry: ghcr.io - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - # Can't run Zenko UI as service as we're unable to attach - # volumes that are located inside the repository - - name: Run Zenko UI - run: > - docker run -d -p 8383:8383 - -v $(pwd)/.github/configs/ui-test-config-shell.json:/usr/share/nginx/html/config-shell.json - -v $(pwd)/.github/configs/ui-test-config.json:/usr/share/nginx/html/config.json - -v $(pwd)/conf/zenko-ui-nginx.conf:/etc/nginx/conf.d/default.conf - ghcr.io/${{ github.repository }}/zenko-ui:${{ github.sha }} - - - name: Wait for all services to start - run: | - bash wait_for_local_port.bash 8082 40 - bash wait_for_local_port.bash 8080 40 - bash wait_for_local_port.bash 8383 40 - - - name: Run end-to-end tests - run: npm run cypress:run - env: - CYPRESS_KEYCLOAK_USER_FULLNAME: "${{ env.KEYCLOAK_USER_FIRSTNAME }} ${{ env.KEYCLOAK_USER_LASTNAME }}" - CYPRESS_KEYCLOAK_USERNAME: "${{ env.KEYCLOAK_USERNAME }}" - CYPRESS_KEYCLOAK_PASSWORD: "${{ env.KEYCLOAK_PASSWORD }}" - CYPRESS_KEYCLOAK_ROOT: "${{ env.KEYCLOAK_ROOT }}" - CYPRESS_KEYCLOAK_CLIENT_ID: "${{ env.KEYCLOAK_CLIENT_ID }}" - CYPRESS_KEYCLOAK_REALM: "${{ env.KEYCLOAK_REALM }}" - - - name: code coverage - uses: codecov/codecov-action@v2.1.0 - - - name: Dump container logs - run: | - docker logs ${{ job.services.keycloak.id }} - docker logs ${{ job.services.shell-ui.id }} - if: always()