Skip to content

Commit

Permalink
Moved validation into generator.js
Browse files Browse the repository at this point in the history
  • Loading branch information
joerx committed Mar 16, 2016
1 parent 86bfc5c commit be6ba58
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -6,9 +6,7 @@ before_script:
- nvm install 4.4
- nvm alias default 4.4
- npm install
- python scraper.py
script:
- node check-uniq-session_id.js
- sh build.sh
env:
- secure: "MA928kGtPidi9F5ciZOogrQnNTZKWPESFq9ew9Mw0wVLu9evcJlFa5WoYXkmOn72hM8qEwoD66R7zb9b+0QS8uHop9QvjG1cjpslzorjE08BU0aMlsx98STPVWB5l8aNOPGE3qhFJmOWm6c+B8lNph61nTMR/4oQ+3+kFvMj4SX9QJ3zZ+VxP/Be5uMkpwySbH9t4rByI4dcvOnwpnsxeuxE7HktNUbuJeAh5nuWuWUgfDrvG2FGgp85zZBQtBTUVAb7ggLNJbdNz6hKOjrVYefqa0bOsoFjbyAtb2vNmfHSsg/xUfBQ/4SSsfYU5jv/uuyp+mdbEb0TLejMNjOCUsIq6bIUe2XgQHJhhHrEtZsUVQEC/1bckxgDFYbmDJcbOQt9j+QAppPkhAoq71IzOnycpmM5zGEZUoOxRIay//Dyg3QyPOJ0Jswce6zKuy8DV5K9aInGBscyY/6Q6Zab7vn0cOYhKEVMSzpKlz4TxGvQm8FGUOqaFFBoxoZlmjzyIeWYqiKRwt7FJgXKEyjbFn8uwt1lZze535eytVgW4Rx4g5QkW6HCQcsQQe0Shqkfb8feDICCw5xPLwUvutrU9/s9HCN/wxpE8nUHhGsODyUl41hCkvocL608wDutgJjhBrQod3wu81Bn8O+ZM/C0XUgvH5LAMxpaMVxg9lMs2Ns="
2 changes: 2 additions & 0 deletions build.sh
Expand Up @@ -5,6 +5,8 @@ set -e
git config --global user.name "Travis CI"
git config --global user.email "noreply+travis@fossasia.org"

python scraper.py

# don't continue if no changes
if git diff-index --quiet HEAD; then
exit 0
Expand Down
20 changes: 0 additions & 20 deletions check-uniq-session_id.js

This file was deleted.

15 changes: 14 additions & 1 deletion schedule/generator.js
Expand Up @@ -99,5 +99,18 @@ function transformData(sessions, speakers) {
return {tracks, days}
}

function validateSessions(sessionsData) {
var ids = sessionsData.map(s => s.session_id)
var dups = ids.filter((sid, idx) => ids.indexOf(sid) !== idx)
if (dups.length > 0) {
console.error('Duplicate session ids: %s', dups.join(', '))
}
return false
}

if (!validateSessions(sessionsData.sessions)) {
process.exit(1)
}

const data = transformData(sessionsData, speakersData)
process.stdout.write(tpl(data))
// process.stdout.write(tpl(data))

1 comment on commit be6ba58

@joerx
Copy link
Contributor Author

@joerx joerx commented on be6ba58 Mar 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move the validation into a separate step of build it into scraper.py to fail the build before we push updated JSON. I don't see that splitting up build.sh and moving parts into .travis-ci.yml makes a lot of sense though - if any build step fails the entire build should fail.

Please sign in to comment.