Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/test project #70

Merged
merged 9 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,28 @@ on:
- v*
workflow_dispatch:

env:
# Common versions
GO_VERSION: "1.20"
DEFAULT_OWNER: "OpenIMSDK"

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

# build chat
- name: Build chat
- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
go-version: ${{ env.GO_VERSION }}

- name: Install Dependencies
run: |
sudo make build
cd scripts
sudo ./build_all_service.sh
sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu \
libbtrfs-dev libgpgme-dev libdevmapper-dev \
qemu-user-static binfmt-support

# docker.io/openim/openim-chat:latest
- name: Extract metadata (tags, labels) for Docker
Expand Down Expand Up @@ -75,6 +84,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta2.outputs.tags }}
labels: ${{ steps.meta2.outputs.labels }}
Expand All @@ -100,4 +110,3 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta3.outputs.tags }}
labels: ${{ steps.meta3.outputs.labels }}

11 changes: 1 addition & 10 deletions .github/workflows/chatci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,4 @@ jobs:
- name: Build source code for host platform
run: |
sudo make build
echo "Build source code for host platform successfully"

# - name: Collect Test Coverage File
# uses: actions/[email protected]
# with:
# name: main-output
# path: _output/tmp/coverage.out

# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v1
echo "Build source code for host platform successfully"
110 changes: 90 additions & 20 deletions .github/workflows/docker-buildx.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,105 @@
name: OpenIM Build Docker Images
name: OpenIM Buildx Docker Images

on:
push:
tags:
- v*
schedule:
- cron: "0 10 * * *"
push:
branches:
- "**"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"

env:
IMAGE_NAME: openim-chat
# Common versions
GO_VERSION: "1.20"
DEFAULT_OWNER: "OpenIMSDK"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
bin:
- openim-chat
# strategy:
# matrix:
# bin:
# - openim-chat
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2

- name: Setup Golang with cache
uses: magnetikonline/action-golang-cache@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
go-version: ${{ env.GO_VERSION }}

- name: Install Dependencies
run: |
sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu \
libbtrfs-dev libgpgme-dev libdevmapper-dev \
qemu-user-static binfmt-support

- name: Docker metadata
id: metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/openim-${{ matrix.bin }}
# list of Docker images to use as base name for tags
# registry.cn-hangzhou.aliyuncs.com/${{github.repository_owner}}/${{env.IMAGE_NAME}}
# ghcr.io/${{github.repository_owner}}/${{env.IMAGE_NAME}}

images: |
openim/${{env.IMAGE_NAME}}

# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and release Docker images
uses: docker/build-push-action@v3
uses: docker/build-push-action@v4
with:
platforms: linux/386,linux/amd64,linux/arm64/v8
target: ${{ matrix.bin }}
tags: ${{ steps.metadata.outputs.tags }}
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }},latest
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}

# - name: Log in to GitHub Container Registry
# uses: docker/login-action@v2
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}

# - name: Log in to AliYun Docker Hub
# uses: docker/login-action@v2
# with:
# registry: registry.cn-hangzhou.aliyuncs.com
# username: ${{ secrets.ALIREGISTRY_USERNAME }}
# password: ${{ secrets.ALIREGISTRY_TOKEN }}

# - name: Build and release Docker images
# uses: docker/build-push-action@v4
# with:
# context: .
# platforms: linux/amd64,linux/arm64
# tags: ${{ steps.meta.outputs.tags }},latest
# push: ${{ github.event_name != 'pull_request' }}
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
go-version: stable
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand Down Expand Up @@ -53,6 +58,7 @@ jobs:
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
USERNAME: ${{ github.repository_owner }}
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro'
# distribution:
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
68 changes: 68 additions & 0 deletions .github/workflows/scripts-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright © 2023 OpenIM. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: OpenIM Start Execute Scripts

on:
push:
branches:
- main
paths-ignore:
- "docs/**"
- "README.md"
- "README_zh-CN.md"
- "CONTRIBUTING.md"
pull_request:
branches:
- main
paths-ignore:
- "README.md"
- "README_zh-CN.md"
- "CONTRIBUTING.md"
- "docs/**"

jobs:
execute-scripts:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Chat
run: |
sudo make build
sudo chmod +x ./scripts/build_all_service.sh
sudo ./scripts/build_all_service.sh
shell: bash

- name: start all services
run: |
sudo chmod +x ./scripts/start_all.sh
sudo ./scripts/start_all.sh
shell: bash

- name: Check all services
run: |
sudo chmod +x ./scripts/check_all.sh
sudo ./scripts/check_all.sh
sudo cat logs/openIM.log 2>/dev/null
shell: bash

- name: Print openIM.log
run: |
sudo cat logs/* 2>/dev/null
sudo cat logs/* 2>/dev/null >> "$GITHUB_OUTPUT"
shell: bash
continue-on-error: true
54 changes: 29 additions & 25 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ dockers:
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
goarch: amd64

- image_templates:
- "openim/openim-chat:{{ .Tag }}-arm64"
Expand All @@ -240,31 +241,31 @@ dockers:
- "--platform=linux/arm64"
goarch: arm64

docker_manifests:
- name_template: "openim/openim-chat:{{ .Tag }}"
image_templates:
- "openim/openim-chat:{{ .Tag }}-amd64"
- "openim/openim-chat:{{ .Tag }}-arm64"
- name_template: "ghcr.io/openimsdk/openim-chat:{{ .Tag }}"
image_templates:
- "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-amd64"
- "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-arm64"
- name_template: "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}"
image_templates:
- "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-amd64"
- "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-arm64"
- name_template: "openim/openim-chat:latest"
image_templates:
- "openim/openim-chat:{{ .Tag }}-amd64"
- "openim/openim-chat:{{ .Tag }}-arm64"
- name_template: "ghcr.io/openimsdk/openim-chat:latest"
image_templates:
- "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-amd64"
- "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-arm64"
- name_template: "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest"
image_templates:
- "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-amd64"
- "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-arm64"
# docker_manifests:
# - name_template: "openim/openim-chat:{{ .Tag }}"
# image_templates:
# - "openim/openim-chat:{{ .Tag }}-amd64"
# - "openim/openim-chat:{{ .Tag }}-arm64"
# - name_template: "ghcr.io/openimsdk/openim-chat:{{ .Tag }}"
# image_templates:
# - "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-amd64"
# - "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-arm64"
# - name_template: "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}"
# image_templates:
# - "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-amd64"
# - "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-arm64"
# - name_template: "openim/openim-chat:latest"
# image_templates:
# - "openim/openim-chat:{{ .Tag }}-amd64"
# - "openim/openim-chat:{{ .Tag }}-arm64"
# - name_template: "ghcr.io/openimsdk/openim-chat:latest"
# image_templates:
# - "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-amd64"
# - "ghcr.io/openimsdk/openim-chat:{{ .Tag }}-arm64"
# - name_template: "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:latest"
# image_templates:
# - "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-amd64"
# - "registry.cn-hangzhou.aliyuncs.com/openimsdk/openim-chat:{{ .Tag }}-arm64"

nfpms:
- id: packages
Expand Down Expand Up @@ -341,6 +342,9 @@ checksum:

release:
footer: |

## Welcome to the {{ .Tag }} release of [chat](https://github.com/OpenIMSDK/chat)!🎉🎉!

**Full Changelog**: https://github.com/OpenIMSDK/chat/compare/{{ .PreviousTag }}...{{ .Tag }}

## Helping out
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ WORKDIR /workspace

ENV GOPROXY=https://goproxy.cn

# Copy go mod and go sum files then download dependencies
COPY go.mod go.sum ./
RUN go mod download

ARG GOARCH
ARG GOOS

# Copy source code files into the image
COPY . .

RUN go mod download

# Compile the source code
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o ./bin/open_im_admin ./cmd/rpc/admin
RUN CGO_ENABLED=0 GOOS=${GOOS} GOARCH=${GOARCH} go build -o ./bin/open_im_admin_api ./cmd/api/admin_api
Expand Down
Loading