codewars / runner

Issue tracker for Code Runner
34 stars 8 forks source link

Add PureScript 0.15.4 #207

Closed andys8 closed 2 years ago

andys8 commented 2 years ago

Please complete the following information:

The current version is 0.12.x from 4 years ago. The PureScript compiler evolved a lot and an upgrade to the recent version 0.15.4 would be awesome. As asked here: Is it possible to contribute or test that the update is working?


kazk commented 2 years ago

PureScript 0.13 was requested (#8), but never got updated because the reporter needs to be updated. Any help to update that is appreciated.

I can open source the image later as well.

andys8 commented 2 years ago

The reporter looks quite simple. I could take a look. But what I'm missing is some context. There seems to be no documentation? How is currently executed? Does it have dependencies and what versions are they, or how are they downloaded. I guess with the docker image and basic instructions it should be possible to update.

kazk commented 2 years ago

I'll clean up and open source the image later. But for now, you should be able to try it out by setting up a PureScript project with the latest version.

It's tested with pulp test. Packages should be updated to the latest.

package.json:

{
  "name": "cw-purescript",
  "version": "0.0.1",
  "description": "",
  "dependencies": {
    "big-integer": "^1.6.41"
  }
}

psc-package.json:

{
  "name": "cw-purescript",
  "set": "psc-0.12.2-20190119",
  "source": "https://github.com/purescript/package-sets.git",
  "depends": [
    "prelude",
    "console",
    "debug",
    "effect",
    "bigints",
    "rationals",
    "profunctor-lenses",
    "spec",
    "spec-discovery",
    "spec-quickcheck"
  ]
}

test/Main.purs:

module Test.Main where

import Prelude
import Data.Maybe (Maybe(..))
import Effect (Effect)

import Test.Spec.Discovery (discover)
import Test.Spec.Runner (defaultConfig, run')

import Test.Spec.Reporter.Codewars (codewarsReporter)

main :: Effect Unit
main = discover ".+Spec" >>= run' config [codewarsReporter]
  where
    config = defaultConfig { timeout = Just 12000 }

test/Example/ExampleSpec.purs:

module Example.ExampleSpec where

import Prelude
import Effect.Aff (delay)
import Data.Time.Duration (Milliseconds(..))

import Test.QuickCheck ((===), (/==))
import Test.Spec (Spec, describe, it)
import Test.Spec.Assertions (shouldEqual)
import Test.Spec.QuickCheck (quickCheck)

spec :: Spec Unit
spec =
  describe "purescript-spec" do
    describe "Attributes" do
      it "awesome" do
        let isAwesome = true
        isAwesome `shouldEqual` true

    describe "Features" do
      it "runs in NodeJS" $ pure unit
      it "runs in the browser" $ pure unit
      it "supports async specs" do
        res <- delay (Milliseconds 100.0) *> pure "Alligator"
        res `shouldEqual` "Alligator"

    describe "QuickCheck" do
      it "works" $
        quickCheck \n -> (n * 2 / 2) === n
      it "works again" $
        quickCheck \n -> ((n + 1) * 2) /== n

    describe "Failure example" do
      it "should fail" do
        1 `shouldEqual` 2

src/Test/Spec/Reporter/Codewars.purs is from that repo.

reactormonk commented 2 years ago

The recommended build tool changed to spago, I have no idea how well supported pulp is nowadays: https://github.com/purescript/spago/blob/master/README.md

andys8 commented 2 years ago

Yeah, I was planning to switch to spago as well.

andys8 commented 2 years ago

Opened a PR. Let's move specific conversation over there: I've added some questions where I'm missing information.

https://github.com/codewars/purescript-spec-reporter-codewars/pull/1

kazk commented 2 years ago

Open sourced the image at https://github.com/codewars/purescript

package.json and psc-package.json I posted above includes dependencies not necessary for the reporter because those are for the project used to test submission. I'd like to properly package the reporter and install it instead of copying src/Test/Spec/Reporter/Codewars.purs.

andys8 commented 2 years ago

Do you want me to update https://github.com/codewars/purescript too?

andys8 commented 2 years ago

Assumed so and opened https://github.com/codewars/purescript/pull/1

kazk commented 2 years ago

Deployed. @andys8 Thanks for your help!

kazk commented 2 years ago

33 kata need updates to enable it. https://www.codewars.com/kata/search/purescript?outdated=true

Use "Fork" on completed kata to update: image

andys8 commented 2 years ago

How to mass update them without completing the katana first? Why are some outdated and some not (13 outdated, 50 total?)

hobovsky commented 2 years ago

How to mass update them without completing the katana first?

To update a kata, you need to either complete it, or forfeit it. Regular users cannot update a kata and keep their eligibility for a reward. If you find a kata which you want to update but you can't, you can contact a user with a mender or mod role and they can help you out. You can use Codewars Discord and #fixing channel there to get in touch with them.

Why are some outdated and some not (13 outdated, 50 total?)

Probably because most of the kata did not use features which stopped working in 0.15. They just happened to work with the new version without any changes. Is it unusual, for some reason? Was transition to 0.15 expected to break all existing kata?

andys8 commented 2 years ago

Was transition to 0.15 expected to break all existing kata?

The previous version was 0.12 which was very outdated and 4 years old. So I'd expect a few breaking changes. But I'm also not surprised if simple katas that don't rely on much still work.

4500zenja1 commented 1 year ago

Maybe it's useful to install the module numbers and some other ones, because some katas can't be upgraded to 0.15.x because they're linked to now deprecated module Math (e.g., this one)?

[error] Some of your project files import modules from packages that are not in the direct dependencies of your project.
To fix this error add the following packages to the list of dependencies in your config:
- numbers
You may add these dependencies by running the following command:
spago install numbers
kazk commented 1 year ago

@4500zenja1 Can you open a PR to update https://github.com/codewars/purescript/blob/main/workspace/spago.dhall ?

4500zenja1 commented 1 year ago

@kazk done

kazk commented 1 year ago

https://github.com/codewars/purescript/pull/4 was deployed.