Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
小滋润 committed Nov 11, 2024
1 parent ab34a89 commit 86fdc62
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions .github/workflows/common-test-and-update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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
docker-compose -f docker-compose.yaml -f docker-compose.override.yaml down

0 comments on commit 86fdc62

Please sign in to comment.