Skip to content

chore: add gas compare back #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

rajkharvar
Copy link
Member

@rajkharvar rajkharvar commented Nov 3, 2023

@rajkharvar rajkharvar marked this pull request as draft November 3, 2023 11:12
@rajkharvar rajkharvar changed the title chore: move back gas compare chore: add gas compare back Nov 6, 2023
@rajkharvar rajkharvar marked this pull request as ready for review November 6, 2023 08:56
SamAg19
SamAg19 previously approved these changes Nov 6, 2023
@hrishikeshio
Copy link
Member

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Possible Issue

The updated URLs in the getJobs and getCollections functions now include /mainnet/. Ensure that this change is intentional and will not break functionality for other environments or configurations.

    const jobs = await axios.get(`${SOURCE}/mainnet/jobs.json`);
    return jobs.data;
  } catch (error) {
    console.log('Error while fetching jobs', error.response.body);
    return null;
  }
};

const getCollections = async () => {
  try {
    const collections = await axios.get(`${SOURCE}/mainnet/collections.json`);
Missing Edge Case Handling

The added code writes "No changes found in gas Consumption" to a file when no changes are detected. Ensure this behavior aligns with the expected functionality and does not introduce unintended issues.

fs.writeFileSync('gasCompareOutput.md', "No changes found in gas Consumption");
Workflow Complexity

The reintroduced gasCompare workflow adds significant complexity. Ensure that all steps, especially branch handling and file operations, are robust and tested for edge cases.

gasCompare:
  runs-on: ubuntu-latest
  needs: install_dependencies
  steps:
    - uses: bissolli/gh-action-persist-workspace@v1
      with:
        action: retrieve
    - name: Run GasCompare
      run: |
        if [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then
          BRANCH_NAME=$GITHUB_HEAD_REF
        else
          BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/\//-/g')
        fi
        echo "Current branch is $BRANCH_NAME"
        if [ "$BRANCH_NAME" == "main" ]; then
          echo "This is the main branch. Exiting..."
          exit 0
        fi
        CI=true npm run test
        mv ./gasReporterOutput.json /tmp/gasReporterOutput_Current.json
        git checkout main
        npm install
        CI=true npm run test
        mv ./gasReporterOutput.json /tmp/gasReporterOutput_Main.json

    - uses: bissolli/gh-action-persist-workspace@v1
      with:
        action: persist

    - name: Checkout
      uses: actions/checkout@v3

    - uses: bissolli/gh-action-persist-workspace@v1
      with:
        action: retrieve

    - name: Run GasCompare
      run: |
        npm run gasCompare /tmp/gasReporterOutput_Current.json /tmp/gasReporterOutput_Main.json

    - name: Comment on the Pull Request
      uses: actions/github-script@v5
      with:
        github-token: ${{secrets.GITHUB_TOKEN}}
        script: |
          const fs = require('fs');
          if (!fs.existsSync('gasCompareOutput.md')) {
            console.log('No gasCompareOutput.md file found.');
            return;
          }
          const markdown = fs.readFileSync('gasCompareOutput.md', 'utf8');
          // Check if markdown content is not empty
          if (markdown.trim().length) {
            await github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: markdown
            });
          } else {
            console.log("No markdown content to comment.");
          }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants