add inter-node ring p2p test #98
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Primus-CI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| jobs: | |
| code-lint: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.12"] | |
| steps: | |
| - run: echo "🎉 Begin Primus Python Lint." | |
| - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | |
| - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | |
| - uses: actions/checkout@v4 | |
| - run: git config --global --add safe.directory /github/workspace | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Display Python version | |
| run: python -c "import sys; print(sys.version)" | |
| - name: Install Autoflake | |
| run: pip install autoflake==v2.3.1 | |
| - name: Run Autoflake | |
| if: always() | |
| run: | | |
| output=$(autoflake . --remove-all-unused-imports --remove-unused-variables --expand-star-imports --ignore-init-module-imports --recursive) | |
| if [[ -n $output ]] | |
| then | |
| echo "Autoflake check failed: $output" | |
| exit 1 | |
| else | |
| echo "Autoflake check success." | |
| exit 0 | |
| fi | |
| - uses: isort/isort-action@v1 | |
| if: always() | |
| with: | |
| configuration: "--profile black --check-only --diff" | |
| - uses: psf/black@stable | |
| if: always() | |
| with: | |
| options: "--check --diff --color --verbose --line-length=110" | |
| run-unittest: | |
| needs: code-lint | |
| runs-on: run-ut | |
| steps: | |
| - run: echo "🎉 Begin Primus Unit Test." | |
| - name: Change owner | |
| run: | | |
| echo "change the owner of all primus files, as some files are generated by root" | |
| echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}" | |
| sudo chown -R $(id -u):$(id -g) ${GITHUB_WORKSPACE} | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| - name: Print dir | |
| run: | | |
| echo "GITHUB_WORKSPACE: ${GITHUB_WORKSPACE}" | |
| echo "current dir: $(pwd)" | |
| - name: Set ut log path | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| echo "UT_LOG_PATH=$GITHUB_WORKSPACE/ut_out/pr-${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
| elif [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| echo "UT_LOG_PATH=$GITHUB_WORKSPACE/ut_out/latest" >> $GITHUB_ENV | |
| elif [[ "${{ github.event_name }}" == "release" ]]; then | |
| TAG_NAME=${{ github.ref }} # refs/tags/v1.0.0 | |
| TAG="${TAG_NAME#refs/tags/}" # v1.0.0 | |
| echo "UT_LOG_PATH=$GITHUB_WORKSPACE/ut_out/$TAG" >> $GITHUB_ENV | |
| else | |
| echo "UT_LOG_PATH=$GITHUB_WORKSPACE/ut_out/others" >> $GITHUB_ENV | |
| fi | |
| - name: Run unit tests | |
| run: | | |
| echo "set UT_LOG_PATH as: ${{ env.UT_LOG_PATH }}" | |
| if [ -d "${{ env.UT_LOG_PATH }}" ]; then | |
| echo "UT_LOG_PATH dir exists. Deleting..." | |
| rm -rf "${{ env.UT_LOG_PATH }}" | |
| fi | |
| docker exec -e UT_LOG_PATH="${{ env.UT_LOG_PATH }}" \ | |
| primus_github_runner bash -c \ | |
| "cd $GITHUB_WORKSPACE && python ./tests/run_unit_tests.py" |