Skip to content

Commit

Permalink
Merge pull request #22 from CivicTechTO/21-fail-prs
Browse files Browse the repository at this point in the history
Fail build process properly when PR's portion of the build fails
  • Loading branch information
patcon authored Oct 21, 2024
2 parents 3e5000f + 150f0ee commit 65cce9d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/deploy-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ jobs:
# Done manually so we can checkout submodule
checkout: false

- name: Fail if PR portion of build failed
if: ${{ github.event_name == 'pull_request_target' }}
shell: bash
env:
DIRECTORY: dist/storybook-bundle/PR-${{ github.event.number }}
run: |
if [ ! -d "$DIRECTORY" ]; then
echo Pull Request build directory "$DIRECTORY does not exist."
exit 1
fi
# See: https://github.com/ouzi-dev/commit-status-updater/pull/533
- uses: patcon/commit-status-updater@patch-1
if: ${{ github.event_name == 'pull_request_target' }}
Expand Down
24 changes: 24 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
/** @type { import('@storybook/react').Preview } */
import "./style.css"
import { getMath, getComments } from "./utils";

// Needed at the very least for Graph component stories of UT-HAI client-deliberation.
import jquery from 'jquery';
global.$ = jquery;
global.jQuery = jquery;

// This is where we mock responses for PolisNet endpoints.
// TODO: Create a storybook plugin to do this dynamically.
function ajax_responses(responses) {
return function (params) {
const mockedPathname = new URL(params.url).pathname
const mockResponse = responses[mockedPathname]
var deferred = global.$.Deferred().resolve(mockResponse)
return deferred
};
}

global.$.ajax = ajax_responses({
'/api/v3/math/pca2': getMath(),
'/api/v3/comments': [getComments()],
'/api/v3/votes': [],
'/api/v3/votes/famous': [],
})

const isGithubBuild = !!process.env["GITHUB_REPOSITORY"]
const preview = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default {
}

// TODO: Need to mock PolisNet API calls.
const Template = (args) => <div>Not Yet Implemented</div>
const Template = (args) => <VisualisationTutorial {...args} />

export const Default = Template.bind({})
Default.args = {}
Default.args = {
// In theory, something happens at 15, but doesn't seem to work.
currentIndex: 14,
}
8 changes: 6 additions & 2 deletions stories/UT-HAI/client-deliberation/Visualization.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import React from 'react'
import Visualization from '../../../codebases/UT-HAI/client-deliberation/src/components/Visualization'
import { withDelibThemeUi } from '../../../.storybook/decorators'



export default {
component: Visualization,
decorators: [withDelibThemeUi],
}

// TODO: Need to mock PolisNet API calls.
const Template = (args) => <div>Not Yet Implemented</div>
const Template = (args) => <Visualization {...args} />

export const Default = Template.bind({})
// No props on this component.
// We pass in all data by mocking jQuery $.ajax calls made by PolisNet.
// See: .storybook/preview.js
Default.args = {}

0 comments on commit 65cce9d

Please sign in to comment.