diff --git a/.github/workflows/build-and-test-workflow.yml b/.github/workflows/build-and-test-workflow.yml new file mode 100644 index 0000000..c7c5068 --- /dev/null +++ b/.github/workflows/build-and-test-workflow.yml @@ -0,0 +1,89 @@ +name: Workflow for Building and Testing + +permissions: + contents: write + +on: + workflow_call: + inputs: + sha: + required: true + type: string + ENVIRONMENT: + required: true + type: string + secrets: + WALLET_PRIVATE_KEY: + required: true + WALLET_ADDRESS: + required: true + RPC_PROVIDER_URL: + required: true + +jobs: + build_and_test: + name: Build and Test + permissions: + contents: write + timeout-minutes: 60 + runs-on: ubuntu-latest + environment: ${{ inputs.ENVIRONMENT }} + strategy: + fail-fast: false + matrix: + python-version: ["3.10"] + env: + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + WALLET_ADDRESS: ${{ secrets.WALLET_ADDRESS }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} + + steps: + - name: Set Timestamp + run: | + echo "TIMESTAMP=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV + + - name: Check out code + uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 + with: + ref: ${{ inputs.sha }} + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install uv + uses: astral-sh/setup-uv@1e862dfacbd1d6d858c55d9b792c756523627244 #v7 + with: + version: "0.9.11" + + - name: Install dependencies + run: uv pip install --system -e ".[dev]" + + - name: Run unit tests + run: | + coverage run -m pytest tests/unit -v -ra -q + coverage report + + - name: Run integration tests + run: | + pytest -v -ra --html=report.html --self-contained-html + + - name: Rename Integration Test Report + run: | + mkdir -p report + mv -f report.html report/report-${{ env.TIMESTAMP }}.html + + - name: Deploy Integration Test Report + uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e #v4.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: report + keep_files: true + allow_empty_commit: true + + - name: Add Github Page Link to Summary + run: | + repo_name=$(echo "${{ github.repository }}" | cut -d'/' -f2) + github_pages_url="https://${{ github.repository_owner }}.github.io/${repo_name}/report-${{ env.TIMESTAMP }}.html" + echo "## 📊Github Page Link: [View Test Report](${github_pages_url})" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/pr-external.yaml b/.github/workflows/pr-external.yaml new file mode 100644 index 0000000..445c00f --- /dev/null +++ b/.github/workflows/pr-external.yaml @@ -0,0 +1,35 @@ +name: Workflow for External PRs with Unit & Integration Tests +permissions: + contents: write + +on: + pull_request_target: + types: [opened, synchronize] + branches: + - main + +jobs: + Timestamp_PR_CREATED: + uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main + authorize: + if: github.event.pull_request.head.repo.full_name != github.repository + needs: [Timestamp_PR_CREATED] + environment: "aeneid" + runs-on: ubuntu-latest + steps: + - run: true + + Timestamp_PR_APPROVED: + needs: [authorize] + uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main + + tests: + needs: [authorize, Timestamp_PR_APPROVED] + uses: ./.github/workflows/build-and-test-workflow.yml + with: + sha: ${{ github.event.pull_request.head.sha }} + ENVIRONMENT: "aeneid" + secrets: + WALLET_ADDRESS: ${{ secrets.WALLET_ADDRESS }} + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }} diff --git a/.github/workflows/pr-internal.yaml b/.github/workflows/pr-internal.yaml new file mode 100644 index 0000000..77b1629 --- /dev/null +++ b/.github/workflows/pr-internal.yaml @@ -0,0 +1,27 @@ +name: Workflow for Internal PRs with Unit & Integration Tests +permissions: + contents: write + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + Timestamp: + if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'workflow_dispatch' }} + uses: storyprotocol/gha-workflows/.github/workflows/reusable-timestamp.yml@main + + tests: + needs: [Timestamp] + uses: ./.github/workflows/build-and-test-workflow.yml + with: + sha: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }} + ENVIRONMENT: "aeneid" + secrets: + WALLET_ADDRESS: ${{ secrets.WALLET_ADDRESS }} + WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }} + RPC_PROVIDER_URL: ${{ secrets.RPC_PROVIDER_URL }}