Coder Social home page Coder Social logo

Comments (6)

simonw avatar simonw commented on June 20, 2024

Here's the failure in CI, which did not cause the workflow to fail even though it should have:

CleanShot 2023-09-21 at 12 50 01@2x

from datasette.

simonw avatar simonw commented on June 20, 2024

The script:

#!/bin/bash
# This should only run in environemnts where both
# datasette-init and datasette-json-html are installed
PLUGINS=$(datasette plugins)
echo "$PLUGINS" | jq 'any(.[]; .name == "datasette-json-html")' | \
grep -q true || ( \
echo "Test failed: datasette-json-html not found" && \
exit 1 \
)
# With the DATASETTE_LOAD_PLUGINS we should not see that
PLUGINS2=$(DATASETTE_LOAD_PLUGINS=datasette-init datasette plugins)
echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-json-html")' | \
grep -q false || ( \
echo "Test failed: datasette-json-html should not have been loaded" && \
exit 1 \
)
echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-init")' | \
grep -q true || ( \
echo "Test failed: datasette-init should have been loaded" && \
exit 1 \
)
# With DATASETTE_LOAD_PLUGINS='' we should see no plugins
PLUGINS3=$(DATASETTE_LOAD_PLUGINS='' datasette plugins)
echo "$PLUGINS3"| \
grep -q '\[\]' || ( \
echo "Test failed: datasette plugins should have returned []" && \
exit 1 \
)

I'm not sure why those exit 1 lines did not cause a CI failure.

from datasette.

simonw avatar simonw commented on June 20, 2024

GPT-4 says:

In the script, you're using a subshell ( ... ) to group commands. If you exit 1 within the subshell, it will only exit the subshell and not the main script. This is why GitHub Actions does not see it as a failure.

It suggested doing this instead:

#!/bin/bash

PLUGINS=$(datasette plugins)
if ! echo "$PLUGINS" | jq 'any(.[]; .name == "datasette-json-html")' | grep -q true; then
  echo "Test failed: datasette-json-html not found"
  exit 1
fi

PLUGINS2=$(DATASETTE_LOAD_PLUGINS=datasette-init datasette plugins)
if ! echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-json-html")' | grep -q false; then
  echo "Test failed: datasette-json-html should not have been loaded"
  exit 1
fi

if ! echo "$PLUGINS2" | jq 'any(.[]; .name == "datasette-init")' | grep -q true; then
  echo "Test failed: datasette-init should have been loaded"
  exit 1
fi

PLUGINS3=$(DATASETTE_LOAD_PLUGINS='' datasette plugins)
if ! echo "$PLUGINS3" | grep -q '\[\]'; then
  echo "Test failed: datasette plugins should have returned []"
  exit 1
fi

from datasette.

simonw avatar simonw commented on June 20, 2024

Yes, the new script seems to work. On Python 3.11:

tests/test-datasette-load-plugins.sh 
echo $?
0

On Python 3.8:

tests/test-datasette-load-plugins.sh
Test failed: datasette-json-html not found
echo $?
1

from datasette.

simonw avatar simonw commented on June 20, 2024

https://github.com/simonw/datasette/actions/runs/6267146158/job/17019594849 failed on 3.9 this time.

    plugin_info["name"] = distinfo.name or distinfo.project_name
AttributeError: 'PathDistribution' object has no attribute 'name'
Test failed: datasette-json-html should not have been loaded

from datasette.

simonw avatar simonw commented on June 20, 2024

The test fails as expected now. Closing this issue, will solve the remaining problems in:

from datasette.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.