diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml deleted file mode 100644 index 1ed18da..0000000 --- a/.github/workflows/build.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: 'Addon Build' - -on: - workflow_dispatch: - push: - branches: - - master - pull_request: - -jobs: - addon-build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Create Addon Zip - run: ./build.sh - - - name: Addon Zip Artifact - uses: actions/upload-artifact@v3 - with: - name: addon-zip - path: data_vis_*.zip diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml new file mode 100644 index 0000000..5e65e07 --- /dev/null +++ b/.github/workflows/build_and_test.yaml @@ -0,0 +1,75 @@ +name: Build and Run Tests + +on: + push: + branches-ignore: + - 'master' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Build Addon + run: python dev/build.py --version 3.0.0 --addon_package data_vis + - name: ZIP Artifact + uses: actions/upload-artifact@v4 + with: + name: data_vis_zip + path: data_vis_3.0.0.zip + + # render_charts: + # runs-on: ubuntu-latest + # needs: build + # steps: + # - uses: actions/checkout@v4 + # - name: Cache Blender + # id: blender_4_2_binary + # uses: actions/cache@v3 + # with: + # path: /home/runner/blender + # key: blender-4.2 + # - name: Download Blender + # if: steps.blenderBinaryCache.outputs.cache-hit != 'true' + # run: curl https://download.blender.org/release/Blender4.2/blender-4.2.5-linux-x64.tar.xz -o /home/runner/blender.tar.xz + # - name: Mkdir + # run: mkdir {/home/runner/.local/bin,/home/runner/blender} -p + # - name: Extract Blender + # if: steps.blenderBinaryCache.outputs.cache-hit != 'true' + # run: tar -xf /home/runner/blender.tar.xz -C /home/runner/blender --strip-components=1 + # - name: Add Blender to PATH + # run: ln -s /home/runner/blender/blender /home/runner/.local/bin/blender + # - name: Download Addon ZIP + # uses: actions/download-artifact@v4 + # with: + # name: data_vis_zip + # - name: Install Blender Dependencies + # run: sudo apt-get install freeglut3-dev + # - name: Install pip dependencies + # if: steps.blenderBinaryCache.outputs.cache-hit != 'true' + # run: /home/runner/blender/4.2/python/bin/python3.11 -m pip install scipy + # - name: Render Charts + # run: python dev/run_in_blender.py --script_path dev/tests/render_charts.py -- data_vis_3.0.0.zip dev/tests/data/ dev/tests/out + # - name: Upload Results + # uses: actions/upload-artifact@v4 + # with: + # name: render_charts_output + # path: dev/tests/out + + comment_on_pr: + runs-on: ubuntu-latest + # needs: render_charts + steps: + - uses: actions/checkout@v4 + # - name: Download Rendered Charts + # uses: actions/download-artifact@v4 + # with: + # name: render_charts_output + - uses: actions/github-script@v7 + with: + script: | + const script = require('.github/workflows/comment_pr.js') + console.log(github) + console.log(context) + console.log(core) + await script({ github, context, core }) \ No newline at end of file diff --git a/.github/workflows/comment_pr.js b/.github/workflows/comment_pr.js new file mode 100644 index 0000000..3a42ea2 --- /dev/null +++ b/.github/workflows/comment_pr.js @@ -0,0 +1,53 @@ +// Thanks to https://github.com/actions/github-script/issues/273#issuecomment-1257245316 + +module.exports = async (github, context, core) => { + // Get pull requests that are open for current ref. + const pullRequests = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + head: `${context.repo.owner}:${context.ref.replace('refs/heads/', '')}` + }) + + // Set issue number for following calls from context (if on pull request event) or from above variable. + const issueNumber = context.issue.number || pullRequests.data[0].number + + // Retrieve existing bot comments for the PR + const {data: comments} = await github.rest.issues.listComments({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + }) + const existingComment = comments.find(comment => { + return comment.user.type === 'Bot' && comment.body.includes('Test') + }) + + // Prepare format of the comment - it has to be de-indented to make markdown work properly. + const output = ` +#### Test + +
+ +*Pusher: @${context.actor}* +*Action: \`${context.eventName}\`* +*Workflow: \`${context.workflow}\`* +*Commit: \`${context.sha}\`* +`; + + // If we have a comment, update it, otherwise create a new one + if (existingComment) { + github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + body: output + }) + } else { + github.rest.issues.createComment({ + issue_number: issueNumber, + owner: context.repo.owner, + repo: context.repo.repo, + body: output + }) + } +} \ No newline at end of file diff --git a/dev/tests/render_charts.py b/dev/tests/render_charts.py index ab0ffef..5ba7a21 100644 --- a/dev/tests/render_charts.py +++ b/dev/tests/render_charts.py @@ -54,43 +54,43 @@ def readable_name(self) -> str: bpy.ops.data_vis.geonodes_line_chart, axis={"X": "Categorical", "Z": "Numeric"}, ), - ChartConfiguration( - "Point Chart Categorical 2D", - "species_2D.csv", - "Cat_2D", - bpy.ops.data_vis.geonodes_point_chart, - axis={"X": "Categorical", "Y": "Numeric"}, - ), - ChartConfiguration( - "Pie Chart Categorical 2D", - "species_2D.csv", - "Cat_2D", - bpy.ops.data_vis.geonodes_pie_chart, - axis={"X": "Categorical", "Y": "Numeric"}, - out_rotation=(math.radians(90), 0, 0), - out_location=(0.5, 0.5, 0.5), - ), - ChartConfiguration( - "Bar Chart Numerical 3D", - "x+y_3D.csv", - "3D", - bpy.ops.data_vis.geonodes_bar_chart, - axis={"X": "Numeric", "Y": "Numeric", "Z": "Numeric"}, - ), - ChartConfiguration( - "Point Chart Numerical 3D", - "x+y_3D.csv", - "3D", - bpy.ops.data_vis.geonodes_point_chart, - axis={"X": "Numeric", "Y": "Numeric", "Z": "Numeric"}, - ), - ChartConfiguration( - "Surface Chart Numerical 3D", - "x+y_3D.csv", - "3D", - bpy.ops.data_vis.geonodes_surface_chart, - axis={"X": "Numeric", "Y": "Numeric", "Z": "Numeric"}, - ), + # ChartConfiguration( + # "Point Chart Categorical 2D", + # "species_2D.csv", + # "Cat_2D", + # bpy.ops.data_vis.geonodes_point_chart, + # axis={"X": "Categorical", "Y": "Numeric"}, + # ), + # ChartConfiguration( + # "Pie Chart Categorical 2D", + # "species_2D.csv", + # "Cat_2D", + # bpy.ops.data_vis.geonodes_pie_chart, + # axis={"X": "Categorical", "Y": "Numeric"}, + # out_rotation=(math.radians(90), 0, 0), + # out_location=(0.5, 0.5, 0.5), + # ), + # ChartConfiguration( + # "Bar Chart Numerical 3D", + # "x+y_3D.csv", + # "3D", + # bpy.ops.data_vis.geonodes_bar_chart, + # axis={"X": "Numeric", "Y": "Numeric", "Z": "Numeric"}, + # ), + # ChartConfiguration( + # "Point Chart Numerical 3D", + # "x+y_3D.csv", + # "3D", + # bpy.ops.data_vis.geonodes_point_chart, + # axis={"X": "Numeric", "Y": "Numeric", "Z": "Numeric"}, + # ), + # ChartConfiguration( + # "Surface Chart Numerical 3D", + # "x+y_3D.csv", + # "3D", + # bpy.ops.data_vis.geonodes_surface_chart, + # axis={"X": "Numeric", "Y": "Numeric", "Z": "Numeric"}, + # ), ]