From e6f73faebdc8cf3d0ec889e1a1015d8e6aba6db8 Mon Sep 17 00:00:00 2001 From: jaeyson Date: Tue, 16 Jul 2024 22:41:32 +0800 Subject: [PATCH] experiment service container in ci --- .github/workflows/test.yml | 92 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..7c85786 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,92 @@ +name: test + +on: + push: + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + typesense-version: ["26.0"] + typesense-port: ["8108:8108"] + + env: + MIX_ENV: test + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + services: + typesense: + image: typesense/typesense:${{ matrix.typesense-version }} + ports: + - ${{matrix.typesense-port}} + options: >- + --health-cmd "curl -f http://localhost:8108/health" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + # - name: Start Typesense + # run: | + # docker run -d \ + # -p ${{ matrix.typesense-port }} \ + # --name typesense \ + # -v /tmp/typesense-data:/data \ + # typesense/typesense:${{ matrix.typesense-version}} \ + # --api-key=xyz \ + # --data-dir /data \ + # --enable-cors + + # - name: Curl Typesense + # run: sleep 1 && curl http://localhost:8108/health + + - name: Setup Elixir/OTP + uses: erlef/setup-beam@v1 + with: + otp-version: "25" + elixir-version: "1.14.x" + + - name: Cache dependencies/builds + uses: actions/cache@v4 + with: + path: | + deps + _build + key: ${{ runner.os }}-mix-typesense-${{ matrix.typesense-version }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-typesense-${{ matrix.typesense-version }} + + - name: Install Dependencies + run: | + mix local.rebar --if-missing + mix local.hex --if-missing + mix deps.get + + - name: Find unused dependencies + run: mix deps.unlock --check-unused + + - name: Check retired dependencies + run: mix hex.audit + + - name: Security audit of dependencies + run: mix deps.audit + + - name: Compile project + run: mix compile --all-warnings + + - name: run static analysis + run: mix credo --all --strict + + - name: check format files + run: mix format --check-formatted + + - name: Run tests + run: mix test + + - name: Post test coverage to Coveralls + run: mix coveralls.github