Merge pull request #1063 from typesense/setup-ci-github-actions

Setup tests in GitHub Actions
This commit is contained in:
Kishore Nallan 2023-08-02 19:26:56 +05:30 committed by GitHub
commit 020876e205
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 32 deletions

View File

@ -1,32 +0,0 @@
version: 2
jobs:
build:
docker:
- image: typesense/typesense-development:03-JAN-2023-1
environment:
- PROJECT_DIR: /typesense
- TYPESENSE_VERSION: $CIRCLE_BRANCH-$CIRCLE_SHA1
working_directory: /typesense
steps:
- checkout
- run:
name: generate cache key source
command: git log --pretty=format:'%H' -n 1 -- cmake CMakeLists.txt build.sh > last-changed-git-sha-for-dependency-listing
- restore_cache:
keys:
- external-Linux-cache-{{ .Branch }}-{{ checksum "last-changed-git-sha-for-dependency-listing" }}
- external-Linux-cache-{{ .Branch }}
- external-Linux-cache
- run:
name: build
command: $PROJECT_DIR/build.sh --clean
- save_cache:
key: external-Linux-cache-{{ .Branch }}-{{ checksum "last-changed-git-sha-for-dependency-listing" }}
paths:
- /typesense/external-Linux
- store_artifacts:
path: /typesense/build-Linux
destination: build
- run:
name: test
command: $PROJECT_DIR/build-Linux/typesense-test

57
.github/workflows/tests.yml vendored Normal file
View File

@ -0,0 +1,57 @@
name: tests
on: [push, pull_request]
# Cancel previous running if a new push is made
# Source: https://stackoverflow.com/a/72408109/123545
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build_and_test:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y g++-10 make git zlib1g-dev m4
# Define the compiler
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 30
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 30
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
- name: Set up Bazel
uses: bazelbuild/setup-bazelisk@v2
- name: Mount bazel cache
uses: actions/cache@v3
with:
path: "~/.cache/bazel"
key: bazel
- name: Build
run: bazel build //:typesense-server
- name: Run tests
run: bazel test //:typesense-test
# Source: https://github.com/actions/upload-artifact/issues/92#issuecomment-1080347032
- run: echo "BAZEL_BIN_FULL_PATH=$(readlink -f bazel-bin)" >> $GITHUB_ENV
- name: Save build artifacts
uses: actions/upload-artifact@v3
with:
name: typesense-server
path: ${{ env.BAZEL_BIN_FULL_PATH }}/typesense-server