ci: Isolate Docker build into steps (#29941)

Co-authored-by: Diego Sampaio <chinello@gmail.com>
pull/29986/head
Guilherme Gazzo 2 years ago committed by GitHub
parent c209d90a29
commit a59841ac7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      .github/actions/setup-node/action.yml
  2. 59
      .github/workflows/ci-test-e2e.yml
  3. 90
      .github/workflows/ci.yml
  4. 2
      apps/meteor/.mocharc.api.js

@ -19,15 +19,15 @@ runs:
using: composite
steps:
# - name: Cache Node Modules
# if: inputs.cache-modules
# id: cache-node-modules
# uses: actions/cache@v3
# with:
# path: |
# node_modules
# **/node_modules
# key: node-modules-${{ hashFiles('yarn.lock') }}
- name: Cache Node Modules
if: inputs.cache-modules
id: cache-node-modules
uses: actions/cache@v3
with:
path: |
node_modules
apps/meteor/node_modules
key: node-modules-${{ hashFiles('yarn.lock') }}
#
# Could use this command to list all paths to save:
# find . -name 'node_modules' -prune | grep -v "/\.meteor/" | grep -v "/meteor/packages/"
@ -37,10 +37,9 @@ runs:
uses: actions/setup-node@v3
with:
node-version: ${{ inputs.node-version }}
cache: ${{ steps.cache-node-modules.outputs.cache-hit != 'true' && 'yarn' || '' }}
cache: 'yarn'
- name: yarn install
# if: inputs.install && steps.cache-node-modules.outputs.cache-hit != 'true'
if: inputs.install
if: steps.cache-node-modules.outputs.cache-hit != 'true'
shell: bash
run: yarn

@ -35,9 +35,6 @@ on:
release:
required: true
type: string
publish-container:
default: false
type: boolean
shard:
default: '[1]'
required: false
@ -118,68 +115,24 @@ jobs:
exit 1
fi
- name: yarn build
run: yarn build
- run: yarn build
- name: Restore build
uses: actions/download-artifact@v3
with:
name: build
path: /tmp/build
- name: Unpack build
run: |
cd /tmp/build
tar xzf Rocket.Chat.tar.gz
rm Rocket.Chat.tar.gz
- name: Start containers
- name: Start containers for CE
if: inputs.release == 'ce'
env:
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
run: |
docker compose -f docker-compose-ci.yml up -d --build rocketchat
# when we are testing CE, we only need to start the rocketchat container
docker compose -f docker-compose-ci.yml up -d rocketchat
- name: Start containers
- name: Start containers for EE
if: inputs.release == 'ee'
env:
MONGO_URL: 'mongodb://host.docker.internal:27017/rocketchat?replicaSet=rs0&directConnection=true'
ENTERPRISE_LICENSE: ${{ inputs.enterprise-license }}
TRANSPORTER: ${{ inputs.transporter }}
run: |
docker compose -f docker-compose-ci.yml up -d --build
- name: Login to GitHub Container Registry
if: inputs.publish-container == true && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Publish Docker images to GitHub Container Registry
if: inputs.publish-container == true && inputs.release == 'ce' && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
run: |
docker compose -f docker-compose-ci.yml push rocketchat
if [[ '${{ matrix.mongodb-version }}' = '4.4' ]]; then
IMAGE_NAME_BASE="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${{ inputs.gh-docker-tag }}"
echo "Push Docker image: ${IMAGE_NAME_BASE}"
docker tag ${IMAGE_NAME_BASE}.official $IMAGE_NAME_BASE
docker push $IMAGE_NAME_BASE
fi;
- name: Publish Docker images (services) to GitHub Container Registry
if: inputs.publish-container == true && inputs.release == 'ee' && (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
run: |
docker compose -f docker-compose-ci.yml push \
authorization-service \
account-service \
ddp-streamer-service \
presence-service \
stream-hub-service
docker compose -f docker-compose-ci.yml up -d
- name: Cache Playwright binaries
if: inputs.type == 'ui'

@ -243,6 +243,86 @@ jobs:
name: build
path: /tmp/Rocket.Chat.tar.gz
build-gh-docker:
name: 🚢 Build Docker Images for Testing
needs: [build, release-versions]
if: (github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'release' || github.ref == 'refs/heads/develop')
runs-on: ubuntu-20.04
env:
RC_DOCKERFILE: ${{ matrix.platform == 'alpine' && needs.release-versions.outputs.rc-dockerfile-alpine || needs.release-versions.outputs.rc-dockerfile }}
RC_DOCKER_TAG: ${{ matrix.platform == 'alpine' && needs.release-versions.outputs.rc-docker-tag-alpine || needs.release-versions.outputs.rc-docker-tag }}
DOCKER_TAG: ${{ needs.release-versions.outputs.gh-docker-tag }}
LOWERCASE_REPOSITORY: ${{ needs.release-versions.outputs.lowercase-repo }}
SERVICES_PUBLISH: 'authorization-service account-service ddp-streamer-service presence-service stream-hub-service'
strategy:
fail-fast: false
matrix:
platform: ['official', 'alpine']
steps:
- uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
- name: Restore build
uses: actions/download-artifact@v3
with:
name: build
path: /tmp/build
- name: Unpack build
run: |
cd /tmp/build
tar xzf Rocket.Chat.tar.gz
rm Rocket.Chat.tar.gz
- uses: dtinth/setup-github-actions-caching-for-turbo@v1
- name: Setup NodeJS
uses: ./.github/actions/setup-node
with:
node-version: ${{ needs.release-versions.outputs.node-version }}
cache-modules: true
install: true
- run: yarn build
- name: Build Docker images
run: |
args=(rocketchat)
if [[ '${{ matrix.platform }}' = 'alpine' ]]; then
args+=($SERVICES_PUBLISH)
fi;
docker compose -f docker-compose-ci.yml build "${args[@]}"
- name: Publish Docker images to GitHub Container Registry
run: |
args=(rocketchat)
if [[ '${{ matrix.platform }}' = 'alpine' ]]; then
args+=($SERVICES_PUBLISH)
fi;
docker compose -f docker-compose-ci.yml push "${args[@]}"
- name: Rename official Docker tag to GitHub Container Registry
if: matrix.platform == 'official'
run: |
IMAGE_NAME_BASE="ghcr.io/${LOWERCASE_REPOSITORY}/rocket.chat:${DOCKER_TAG}"
echo "Push Docker image: ${IMAGE_NAME_BASE}"
docker tag ${IMAGE_NAME_BASE}.official $IMAGE_NAME_BASE
docker push $IMAGE_NAME_BASE
checks:
needs: [release-versions, packages-build]
@ -261,13 +341,12 @@ jobs:
test-api:
name: 🔨 Test API (CE)
needs: [checks, build, release-versions]
needs: [checks, build-gh-docker, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
type: api
release: ce
publish-container: true
node-version: ${{ needs.release-versions.outputs.node-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
rc-dockerfile: ${{ needs.release-versions.outputs.rc-dockerfile }}
@ -281,7 +360,7 @@ jobs:
test-ui:
name: 🔨 Test UI (CE)
needs: [checks, build, release-versions]
needs: [checks, build-gh-docker, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
@ -307,7 +386,7 @@ jobs:
test-api-ee:
name: 🔨 Test API (EE)
needs: [checks, build, release-versions]
needs: [checks, build-gh-docker, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:
@ -315,7 +394,6 @@ jobs:
release: ee
transporter: 'nats://nats:4222'
enterprise-license: ${{ needs.release-versions.outputs.enterprise-license }}
publish-container: true
mongodb-version: "['4.4']"
node-version: ${{ needs.release-versions.outputs.node-version }}
lowercase-repo: ${{ needs.release-versions.outputs.lowercase-repo }}
@ -330,7 +408,7 @@ jobs:
test-ui-ee:
name: 🔨 Test UI (EE)
needs: [checks, build, release-versions]
needs: [checks, build-gh-docker, release-versions]
uses: ./.github/workflows/ci-test-e2e.yml
with:

@ -9,5 +9,5 @@ module.exports = {
timeout: 10000,
bail: true,
file: 'tests/end-to-end/teardown.js',
spec: ['tests/unit/app/api/server/v1/**/*.spec.*', 'tests/end-to-end/api/**/*', 'tests/end-to-end/apps/*'],
spec: ['tests/end-to-end/api/**/*', 'tests/end-to-end/apps/*'],
};

Loading…
Cancel
Save