diff --git a/.github/workflows/common-test-and-update-docs.yml b/.github/workflows/common-test-and-update-docs.yml index d1269f6..ed30de1 100644 --- a/.github/workflows/common-test-and-update-docs.yml +++ b/.github/workflows/common-test-and-update-docs.yml @@ -22,11 +22,19 @@ jobs: run: | docker build -t xiaozirun/leap-ledger:latest -f docker/Dockerfile . + - name: Install yq + run: | + sudo wget https://github.com/mikefarah/yq/releases/download/v4.6.3/yq_linux_amd64 -O /usr/local/bin/yq + sudo chmod +x /usr/local/bin/yq + - name: Set up Docker Compose run: | - sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo curl -L "https://github.com/docker/compose/releases/download/2.10.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose + - name: Copy docker-compose.yaml to docker-compose.override.yaml + run: cp docker-compose.yaml docker-compose.override.yaml + - name: Start mysql run: | docker-compose -f docker-compose.yaml up -d leap-ledger-mysql @@ -44,22 +52,17 @@ jobs: retries=$((retries + 1)) echo "Waiting for MySQL to be ready... Retry $retries/$max_retries" sleep 5 - done - echo "MySQL is ready!" + done" - - name: Start server + - name: Update test command in docker-compose.override.yaml run: | - docker-compose -f docker-compose.yaml up -d - - - name: Wait for 60 seconds - run: sleep 60 + command="go install github.com/jstemmer/go-junit-report@latest && go test -timeout 5m -v 2>&1 ./... -coverprofile=docs/coverage.out | go-junit-report > docs/test-report.xml" + yq eval ".services.leap-ledger-server.command = \"$command\"" -i docker-compose.override.yaml + shell: bash - - name: Run tests and make report + - name: Exec test run: | - docker-compose logs leap-ledger-server - docker exec leap-ledger-server sh -c "go install github.com/jstemmer/go-junit-report@latest" - docker exec leap-ledger-server sh -c "go test -timeout 5m -v 2>&1 ./... -coverprofile=docs/coverage.out | go-junit-report > docs/test-report.xml" - continue-on-error: false + docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d - name: Upload test-report.xml uses: actions/upload-artifact@v4 @@ -82,11 +85,17 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - - name: Execute updateDocs.sh in container - run: docker exec leap-ledger-server sh "./docs/updateDocs.sh" + - name: Update docs command in docker-compose.override.yaml + run: | + command="./docs/updateDocs.sh" + yq eval ".services.leap-ledger-server.command = \"$command\"" -i docker-compose.override.yaml + shell: bash + + - name: Exec updateDocs.sh + run: | + docker-compose -f docker-compose.yaml -f docker-compose.override.yaml up -d - name: Commit and push changes - # https://github.com/actions/checkout/discussions/479 run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" @@ -96,9 +105,8 @@ jobs: else git commit -m "update docs" || echo "No changes to commit." git push origin ${{ inputs.ref }} - fi continue-on-error: true - name: Docker Compose Down run: | - docker-compose -f docker-compose.yaml down \ No newline at end of file + docker-compose -f docker-compose.yaml -f docker-compose.override.yaml down