diff --git a/.github/workflows/phi-unphi-test.yml b/.github/workflows/phi-unphi-test.yml new file mode 100644 index 0000000000..f58ff43721 --- /dev/null +++ b/.github/workflows/phi-unphi-test.yml @@ -0,0 +1,36 @@ +name: "Pipeline: eo -> phi -> unphi -> eo -> test" + +on: + push: + workflow_dispatch: + +jobs: + pipeline: + name: Run pipeline + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + fail-fast: false + + steps: + - name: 📥 Checkout repository + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: actions/setup-java@v4 + with: + distribution: "zulu" + java-version: 21 + + - uses: freckle/stack-action@v5 + with: + working-directory: pipeline + + - name: Run pipeline + shell: bash + working-directory: pipeline + run: ./run.sh diff --git a/.gitignore b/.gitignore index 8b4f3b290d..7d9114f2b5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ target/ .classpath .recommenders .mvn/wrapper/maven-wrapper.jar -.factorypath \ No newline at end of file +.factorypath +.direnv +. \ No newline at end of file diff --git a/pipeline/.envrc b/pipeline/.envrc new file mode 100644 index 0000000000..8392d159f2 --- /dev/null +++ b/pipeline/.envrc @@ -0,0 +1 @@ +use flake \ No newline at end of file diff --git a/pipeline/.gitignore b/pipeline/.gitignore new file mode 100644 index 0000000000..0396739c67 --- /dev/null +++ b/pipeline/.gitignore @@ -0,0 +1,3 @@ +node_modules +.stack-work +.data \ No newline at end of file diff --git a/pipeline/config.yaml b/pipeline/config.yaml new file mode 100644 index 0000000000..5d26f3333f --- /dev/null +++ b/pipeline/config.yaml @@ -0,0 +1,96 @@ +sets: +- source: ../eo-runtime/src/test/eo/org/eolang/as-phi-tests.eo + yaml: .data/yaml/as-phi-tests.yaml + destination: .data/eo/as-phi-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/bool-tests.eo + yaml: .data/yaml/bool-tests.yaml + destination: .data/eo/bool-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/bytes-tests.eo + yaml: .data/yaml/bytes-tests.yaml + destination: .data/eo/bytes-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/cage-tests.eo + yaml: .data/yaml/cage-tests.yaml + destination: .data/eo/cage-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/cti-test.eo + yaml: .data/yaml/cti-test.yaml + destination: .data/eo/cti-test.eo +- source: ../eo-runtime/src/test/eo/org/eolang/float-tests.eo + yaml: .data/yaml/float-tests.yaml + destination: .data/eo/float-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/goto-tests.eo + yaml: .data/yaml/goto-tests.yaml + destination: .data/eo/goto-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/heap-tests.eo + yaml: .data/yaml/heap-tests.yaml + destination: .data/eo/heap-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/int-tests.eo + yaml: .data/yaml/int-tests.yaml + destination: .data/eo/int-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/memory-tests.eo + yaml: .data/yaml/memory-tests.yaml + destination: .data/eo/memory-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/nan-tests.eo + yaml: .data/yaml/nan-tests.yaml + destination: .data/eo/nan-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/negative-infinity-tests.eo + yaml: .data/yaml/negative-infinity-tests.yaml + destination: .data/eo/negative-infinity-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/nop-tests.eo + yaml: .data/yaml/nop-tests.yaml + destination: .data/eo/nop-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/positive-infinity-tests.eo + yaml: .data/yaml/positive-infinity-tests.yaml + destination: .data/eo/positive-infinity-tests.eo + exclude: + - float-equal-to-nan-and-infinites-is-false-highload +- source: ../eo-runtime/src/test/eo/org/eolang/ram-tests.eo + yaml: .data/yaml/ram-tests.yaml + destination: .data/eo/ram-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/runtime-tests.eo + yaml: .data/yaml/runtime-tests.yaml + destination: .data/eo/runtime-tests.eo + exclude: + - constant-defends-against-side-effects +- source: ../eo-runtime/src/test/eo/org/eolang/rust-tests.eo + yaml: .data/yaml/rust-tests.yaml + destination: .data/eo/rust-tests.eo + enable: false +- source: ../eo-runtime/src/test/eo/org/eolang/seq-tests.eo + yaml: .data/yaml/seq-tests.yaml + destination: .data/eo/seq-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/string-tests.eo + yaml: .data/yaml/string-tests.yaml + destination: .data/eo/string-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/switch-tests.eo + yaml: .data/yaml/switch-tests.yaml + destination: .data/eo/switch-tests.eo + exclude: + - switch-complex-case + - switch-simple-case + # fails on windows + - switch-strings-case + # fails on windows + - switch-with-all-false-cases + # fails on windows + - switch-with-several-true-cases +- source: ../eo-runtime/src/test/eo/org/eolang/try-tests.eo + yaml: .data/yaml/try-tests.yaml + destination: .data/eo/try-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/tuple-tests.eo + yaml: .data/yaml/tuple-tests.yaml + destination: .data/eo/tuple-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/unit-tests.eo + yaml: .data/yaml/unit-tests.yaml + destination: .data/eo/unit-tests.eo +- source: ../eo-runtime/src/test/eo/org/eolang/io/stdout-tests.eo + yaml: .data/yaml/io/stdout-tests.yaml + destination: .data/eo/io/stdout-tests.eo + enable: false +- source: ../eo-runtime/src/test/eo/org/eolang/io/tupled-stdout-test.eo + yaml: .data/yaml/io/tupled-stdout-test.yaml + destination: .data/eo/io/tupled-stdout-test.eo + enable: false +- source: ../eo-runtime/src/test/eo/org/eolang/io/tupled-stdout.eo + yaml: .data/yaml/io/tupled-stdout.yaml + destination: .data/eo/io/tupled-stdout.eo + enable: false diff --git a/pipeline/flake.lock b/pipeline/flake.lock new file mode 100644 index 0000000000..c0d4c205c8 --- /dev/null +++ b/pipeline/flake.lock @@ -0,0 +1,130 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1705634019, + "narHash": "sha256-HHrEr99Y094RWMxzsi3mm+Y8YkkXYydemHVRXDeW4w4=", + "owner": "deemp", + "repo": "devshell", + "rev": "c6f33b92c7023e1e38e8108174e64e4d736fc5ee", + "type": "github" + }, + "original": { + "owner": "deemp", + "ref": "add-interpolate-menu", + "repo": "devshell", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1709826546, + "narHash": "sha256-5V0lRvF/xZpspzMBx5z0sUy0kVBYnFEuwrMCmyfqXME=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b4bd062bd409301d5e3e725f1bf2894ecd8bfd28", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/pipeline/flake.nix b/pipeline/flake.nix new file mode 100644 index 0000000000..b2c37b389f --- /dev/null +++ b/pipeline/flake.nix @@ -0,0 +1,21 @@ +{ + inputs.nixpkgs.url = "github:nixos/nixpkgs"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.devshell.url = "github:deemp/devshell/add-interpolate-menu"; + outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system: + let + pkgs = inputs.nixpkgs.legacyPackages.${system}; + inherit (pkgs.extend inputs.devshell.overlays.default) devshell; + devShells.default = devshell.mkShell { + commands = { + tools = [ + pkgs.stack + ]; + }; + }; + in + { + inherit devShells; + } + ); +} diff --git a/pipeline/package-lock.json b/pipeline/package-lock.json new file mode 100644 index 0000000000..664a59e9b6 --- /dev/null +++ b/pipeline/package-lock.json @@ -0,0 +1,656 @@ +{ + "name": "eo", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "eolang": "^0.18.0" + } + }, + "node_modules/@types/concat-stream": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/@types/concat-stream/-/concat-stream-1.6.1.tgz", + "integrity": "sha512-eHE4cQPoj6ngxBZMvVf6Hw7Mh4jMW4U9lpGmS5GBPB9RYxlFg+CHaVN7ErNY4W9XfLIEn20b4VDYaIrbq0q4uA==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/form-data": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-0.0.33.tgz", + "integrity": "sha512-8BSvG1kGm83cyJITQMZSulnl6QV8jqAGreJsc5tPu1Jq0vTSOiY/k24Wx82JRpWwZSqrala6sd5rWi6aNXvqcw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/node": { + "version": "10.17.60", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.60.tgz", + "integrity": "sha512-F0KIgDJfy2nA3zMLmWGKxcH2ZVEtCZXHHdOQs2gSaQ27+lNeEfGxzkIw90aXswATX7AZ33tahPbzy6KAfUreVw==", + "dev": true + }, + "node_modules/@types/qs": { + "version": "6.9.11", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.11.tgz", + "integrity": "sha512-oGk0gmhnEJK4Yyk+oI7EfXsLayXatCWPHary1MtcmbAifkobT9cM9yutG/hZKIseOU0MqbIwQ/u2nn/Gb+ltuQ==", + "dev": true + }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", + "dev": true + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true + }, + "node_modules/call-bind": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.6.tgz", + "integrity": "sha512-Mj50FLHtlsoVfRfnHaZvyrooHcrlceNZdL/QBvJJVd9Ta55qCQK0gs4ss2oZDeV9zFCs6ewzYgVE5yfVmfFpVg==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.3", + "set-function-length": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==", + "dev": true + }, + "node_modules/colors": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", + "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", + "dev": true, + "engines": { + "node": ">=0.1.90" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/commander": { + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-12.0.0.tgz", + "integrity": "sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==", + "dev": true, + "engines": { + "node": ">=18" + } + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "dev": true + }, + "node_modules/define-data-property": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", + "integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.2", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/eolang": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/eolang/-/eolang-0.18.0.tgz", + "integrity": "sha512-QepfFJ+aVFQdIjFEQm8TSCVAK6c5SpKBg9/TZq/Vqdbb9FXJKrn5loZQAInsG4+YM1GSZfW/fhtu4tB45Fk9Bg==", + "dev": true, + "os": [ + "darwin", + "linux", + "win32" + ], + "dependencies": { + "colors": "1.4.0", + "commander": "12.0.0", + "fast-xml-parser": "4.3.5", + "node": "21.6.1", + "relative": "3.0.2", + "semver": "7.6.0", + "sync-request": "6.1.0", + "xmlhttprequest": "1.8.0" + }, + "bin": { + "eoc": "src/eoc.js" + }, + "engines": { + "node": ">6.0", + "npm": ">8.0" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/fast-xml-parser": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.3.5.tgz", + "integrity": "sha512-sWvP1Pl8H03B8oFJpFR3HE31HUfwtX7Rlf9BNsvdpujD4n7WMhfmu8h9wOV2u+c1k0ZilTADhPqypzx2J690ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/NaturalIntelligence" + }, + { + "type": "paypal", + "url": "https://paypal.me/naturalintelligence" + } + ], + "dependencies": { + "strnum": "^1.0.5" + }, + "bin": { + "fxparser": "src/cli/cli.js" + } + }, + "node_modules/form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dev": true, + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-port": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/get-port/-/get-port-3.2.0.tgz", + "integrity": "sha512-x5UJKlgeUiNT8nyo/AcnwLnZuZNcSjSw0kogRB+Whd1fjjFq4B1hySFxSFWWSn4mIBzg3sRNUDFYc4g5gjPoLg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", + "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", + "dev": true, + "dependencies": { + "get-intrinsic": "^1.2.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", + "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", + "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-basic": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/http-basic/-/http-basic-8.1.3.tgz", + "integrity": "sha512-/EcDMwJZh3mABI2NhGfHOGOeOZITqfkEO4p/xK+l3NpyncIHUQBoMvCSF/b5GqvKtySC2srL/GGG3+EtlqlmCw==", + "dev": true, + "dependencies": { + "caseless": "^0.12.0", + "concat-stream": "^1.6.2", + "http-response-object": "^3.0.1", + "parse-cache-control": "^1.0.1" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/http-response-object": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/http-response-object/-/http-response-object-3.0.2.tgz", + "integrity": "sha512-bqX0XTF6fnXSQcEJ2Iuyr75yVakyjIDCqroJQ/aHfSdlM743Cwqoi2nDYMzLGWUcuTWGWy8AAvOKXTfiv6q9RA==", + "dev": true, + "dependencies": { + "@types/node": "^10.0.3" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "dev": true + }, + "node_modules/isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha512-+OUdGJlgjOBZDfxnDjYYG6zp487z0JGNQq3cYQYg5f5hKR+syHMsaztzGeml/4kGG55CSpKSpWTY+jYGgsHLgA==", + "dev": true, + "dependencies": { + "isarray": "1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node": { + "version": "21.6.1", + "resolved": "https://registry.npmjs.org/node/-/node-21.6.1.tgz", + "integrity": "sha512-cTqZk0/Wl6qeVcftyriVhHGFw1xvXl9o8TPI/qLcoVKh6X1dDKJGVi+EbhUg6864+KoDBnEaVxre59W8r8cLcA==", + "dev": true, + "hasInstallScript": true, + "dependencies": { + "node-bin-setup": "^1.0.0" + }, + "bin": { + "node": "bin/node" + }, + "engines": { + "npm": ">=5.0.0" + } + }, + "node_modules/node-bin-setup": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/node-bin-setup/-/node-bin-setup-1.1.3.tgz", + "integrity": "sha512-opgw9iSCAzT2+6wJOETCpeRYAQxSopqQ2z+N6BXwIMsQQ7Zj5M8MaafQY8JMlolRR6R1UXg2WmhKp0p9lSOivg==", + "dev": true + }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/parse-cache-control": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parse-cache-control/-/parse-cache-control-1.0.1.tgz", + "integrity": "sha512-60zvsJReQPX5/QP0Kzfd/VrpjScIQ7SHBW6bFCYfEP+fp0Eppr1SHhIO5nd1PjZtvclzSzES9D/p5nFJurwfWg==", + "dev": true + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true + }, + "node_modules/promise": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/promise/-/promise-8.3.0.tgz", + "integrity": "sha512-rZPNPKTOYVNEEKFaq1HqTgOwZD+4/YHS5ukLzQCypkj+OkYx7iv0mA91lJlpPPZ8vMau3IIGj5Qlwrx+8iiSmg==", + "dev": true, + "dependencies": { + "asap": "~2.0.6" + } + }, + "node_modules/qs": { + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.2.tgz", + "integrity": "sha512-tDNIz22aBzCDxLtVH++VnTfzxlfeK5CbqohpSqpJgj1Wg/cQbStNAz3NuqCs5vV+pjBsK4x4pN9HlVh7rcYRiA==", + "dev": true, + "dependencies": { + "side-channel": "^1.0.4" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "dev": true, + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/relative": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/relative/-/relative-3.0.2.tgz", + "integrity": "sha512-Q5W2qeYtY9GbiR8z1yHNZ1DGhyjb4AnLEjt8iE6XfcC1QIu+FAtj3HQaO0wH28H1mX6cqNLvAqWhP402dxJGyA==", + "dev": true, + "dependencies": { + "isobject": "^2.0.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/semver": { + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/set-function-length": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", + "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", + "dev": true, + "dependencies": { + "define-data-property": "^1.1.2", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.3", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/side-channel": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", + "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.6", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/strnum": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/strnum/-/strnum-1.0.5.tgz", + "integrity": "sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==", + "dev": true + }, + "node_modules/sync-request": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/sync-request/-/sync-request-6.1.0.tgz", + "integrity": "sha512-8fjNkrNlNCrVc/av+Jn+xxqfCjYaBoHqCsDz6mt030UMxJGr+GSfCV1dQt2gRtlL63+VPidwDVLr7V2OcTSdRw==", + "dev": true, + "dependencies": { + "http-response-object": "^3.0.1", + "sync-rpc": "^1.2.1", + "then-request": "^6.0.0" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/sync-rpc": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/sync-rpc/-/sync-rpc-1.3.6.tgz", + "integrity": "sha512-J8jTXuZzRlvU7HemDgHi3pGnh/rkoqR/OZSjhTyyZrEkkYQbk7Z33AXp37mkPfPpfdOuj7Ex3H/TJM1z48uPQw==", + "dev": true, + "dependencies": { + "get-port": "^3.1.0" + } + }, + "node_modules/then-request": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/then-request/-/then-request-6.0.2.tgz", + "integrity": "sha512-3ZBiG7JvP3wbDzA9iNY5zJQcHL4jn/0BWtXIkagfz7QgOL/LqjCEOBQuJNZfu0XYnv5JhKh+cDxCPM4ILrqruA==", + "dev": true, + "dependencies": { + "@types/concat-stream": "^1.6.0", + "@types/form-data": "0.0.33", + "@types/node": "^8.0.0", + "@types/qs": "^6.2.31", + "caseless": "~0.12.0", + "concat-stream": "^1.6.0", + "form-data": "^2.2.0", + "http-basic": "^8.1.1", + "http-response-object": "^3.0.1", + "promise": "^8.0.0", + "qs": "^6.4.0" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/then-request/node_modules/@types/node": { + "version": "8.10.66", + "resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.66.tgz", + "integrity": "sha512-tktOkFUA4kXx2hhhrB8bIFb5TbwzS4uOhKEmwiD+NoiL0qtP2OQ9mFldbgD4dV1djrlBYP6eBuQZiWjuHUpqFw==", + "dev": true + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", + "dev": true + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "dev": true + }, + "node_modules/xmlhttprequest": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", + "integrity": "sha512-58Im/U0mlVBLM38NdZjHyhuMtCqa61469k2YP/AaPbvCoV9aQGUpbJBj1QRm2ytRiVQBD/fsw7L2bJGDVQswBA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + }, + "devDependencies": { + "eoc": "^0.15.1" + } +} diff --git a/pipeline/package.json b/pipeline/package.json new file mode 100644 index 0000000000..87cf6e8710 --- /dev/null +++ b/pipeline/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "eolang": "^0.18.0" + } +} diff --git a/pipeline/run.sh b/pipeline/run.sh new file mode 100755 index 0000000000..c68e2bcc2c --- /dev/null +++ b/pipeline/run.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -euo pipefail + +if ! [ -d node_modules ]; then npm i; fi + +export LC_ALL=C.UTF-8 + +shopt -s extglob +shopt -s expand_aliases + +alias eo="npx eoc --parser=0.35.11" + +DATA_DIR=".data" + +function prepare_directory { + printf "\nClean %s directory\n\n" "$DATA_DIR" + + rm -rf "$DATA_DIR" + + printf "\nGenerate EO test files\n\n" + + stack run transform-eo-tests +} + +function enter_directory { + printf "\nEnter the %s directory\n\n" "$DATA_DIR" + + mkdir -p "$DATA_DIR" + cd "$DATA_DIR" +} + +function tests_without_normalization { + printf "\nConvert EO to PHI\n\n" + + mkdir -p phi + cd eo + eo clean + eo phi + cp -r .eoc/phi/!(org) ../phi + cd .. + + + printf "\nConvert PHI to EO without normalization\n\n" + + mkdir -p eo-not-normalized + cd phi + cp -r ../eo/.eoc . + eo unphi --tests + cp -r .eoc/unphi/!(org) .eoc/2-optimize + eo print + cp -r .eoc/print/!(org) ../eo-not-normalized + cd .. + + printf "\nTest EO without normalization\n\n" + + cd eo-not-normalized + eo test + cd .. +} + +prepare_directory +enter_directory +tests_without_normalization diff --git a/pipeline/stack.yaml b/pipeline/stack.yaml new file mode 100644 index 0000000000..1998ca6bd9 --- /dev/null +++ b/pipeline/stack.yaml @@ -0,0 +1,3 @@ +resolver: lts-22.6 +packages: +- transform-eo-tests diff --git a/pipeline/stack.yaml.lock b/pipeline/stack.yaml.lock new file mode 100644 index 0000000000..1b74b0a3e2 --- /dev/null +++ b/pipeline/stack.yaml.lock @@ -0,0 +1,12 @@ +# This file was autogenerated by Stack. +# You should not edit this file by hand. +# For more information, please see the documentation at: +# https://docs.haskellstack.org/en/stable/lock_files + +packages: [] +snapshots: +- completed: + sha256: 1b4c2669e26fa828451830ed4725e4d406acc25a1fa24fcc039465dd13d7a575 + size: 714100 + url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/6.yaml + original: lts-22.6 diff --git a/pipeline/transform-eo-tests/app/Main.hs b/pipeline/transform-eo-tests/app/Main.hs new file mode 100644 index 0000000000..8392960fd5 --- /dev/null +++ b/pipeline/transform-eo-tests/app/Main.hs @@ -0,0 +1,147 @@ +{-# LANGUAGE BlockArguments #-} +{-# LANGUAGE DeriveAnyClass #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE DuplicateRecordFields #-} +{-# LANGUAGE InstanceSigs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE OverloadedRecordDot #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE ViewPatterns #-} + +module Main (main) where + +import Control.Monad +import Data.Function ((&)) +import Data.Functor ((<&>)) +import Data.Maybe (fromMaybe) +import Data.String (IsString (..)) +import Data.Text qualified as T +import Data.Yaml (FromJSON, ToJSON (..), Value (String), decodeFileThrow, encodeFile) +import Data.Yaml qualified as Yaml +import Data.Yaml.Aeson (FromJSON (..), withText) +import GHC.Generics (Generic) +import Main.Utf8 (withUtf8) +import System.Directory.Extra (createDirectoryIfMissing, removeFile) +import System.FilePath.Posix +import Text.Read (readMaybe) +import Options.Applicative + +configPathParser :: Parser (Maybe FilePath) +configPathParser = optional $ strArgument (metavar "FILE" <> help "Config FILE. Defaults to ./config.yaml") + +opts :: ParserInfo (Maybe FilePath) +opts = info (configPathParser <**> helper) (fullDesc <> progDesc "Transform EO tests") + +main :: IO () +main = withUtf8 do + configPath <- fromMaybe "./config.yaml" <$> customExecParser (prefs showHelpOnEmpty) opts + config <- decodeFileThrow @_ @TestConfig configPath + forM_ (filter (fromMaybe True . (.enable)) config.sets) $ \set -> do + test@Test{source, meta} <- parseTest set.source + let exclude = fromMaybe [] set.exclude + include = fromMaybe (test.programs <&> (.name)) set.include & filter (`notElem` exclude) + programs = filter (\x -> x.name `elem` include) test.programs + testContent = TestContent{..} + + -- write yaml + let target = set.yaml + targetTmp = target <.> ".tmp" + createDirectoryIfMissing True (takeDirectory target) + encodeFile targetTmp testContent + readFile targetTmp >>= appendFile target + removeFile targetTmp + + -- write eo + createDirectoryIfMissing True (takeDirectory set.destination) + writeFile set.destination meta + forM_ programs (\x -> appendFile set.destination x.text) + +data TestSet = TestSet + { source :: FilePath + , yaml :: FilePath + , destination :: FilePath + , include :: Maybe [String] + -- ^ + -- Program names to include. + -- + -- `Nothing` is equivalent to all programs. + , exclude :: Maybe [String] + -- ^ + -- Program names to exclude + -- + -- `Nothing` is equivalent to no programs. + , enable :: Maybe Bool + -- ^ + -- Whether to enable this test set. + } + deriving (Show, Generic, FromJSON) + +data TestConfig = TestConfig + { sets :: [TestSet] + } + deriving (Show, Generic, FromJSON) + +data Pos = Pos + { file :: FilePath + , line :: Int + } + deriving (Show) + +instance ToJSON Pos where + toJSON :: Pos -> Value + toJSON Pos{..} = String (fromString (file <> ":" <> show line)) + +instance FromJSON Pos where + parseJSON :: Value -> Yaml.Parser Pos + parseJSON = withText "Pos" $ \(T.unpack -> x) -> do + let (file, rs) = span (/= ':') x + guard (not . null $ file) + guard (length rs > 1) + let line' = readMaybe (drop 1 rs) + maybe (fail $ x <> " is not a number") (\line -> pure Pos{..}) line' + +data Program = Program + { source :: Pos + , name :: String + , text :: String + } + deriving (Show, Generic, ToJSON, FromJSON) + +data Test = Test + { source :: String + , license :: String + , meta :: String + , programs :: [Program] + } + deriving (Show, Generic, ToJSON, FromJSON) + +data TestContent = TestContent + { source :: FilePath + , meta :: String + , programs :: [Program] + } + deriving (Show, Generic, ToJSON, FromJSON) + +parseProgramsRaw :: ([(Int, [String])], (Int, [[Char]]), Int) -> [[Char]] -> [(Int, String)] +parseProgramsRaw (programs', (programStart, program), curLine) (line'@(x : _) : xs) + | (program /= [] && head program == "" || null program) && (x == '[' || x == '#') = parseProgramsRaw ((programStart, program) : programs', (curLine, [line']), curLine + 1) xs + | otherwise = parseProgramsRaw (programs', (programStart, line' : program), curLine + 1) xs +parseProgramsRaw (programs', (programStart, program), curLine) ("" : xs) = parseProgramsRaw (programs', (programStart, "" : program), curLine + 1) xs +parseProgramsRaw (programs', program, _) [] = (unlines <$>) <$> drop 1 (reverse ((reverse <$>) <$> (program : programs'))) + +parseTest' :: FilePath -> [String] -> Test +parseTest' source eoCode = + let + (license, k') = span (\case '#' : _ -> True; "" -> True; _ -> False) eoCode + (meta, k'') = span (\case '+' : _ -> True; "" -> True; _ -> False) k' + programsStart = length license + length meta + 1 + programsRaw = parseProgramsRaw ([], (programsStart, []), programsStart) k'' + programs = programsRaw <&> (\(line, text) -> Program{source = Pos{file = source, ..}, name = text & dropWhile (/= '[') & drop 5 & takeWhile (/= '\n'), ..}) + in + Test{license = unlines license, meta = unlines meta, ..} + +parseTest :: FilePath -> IO Test +parseTest path = readFile path <&> (parseTest' path . lines) diff --git a/pipeline/transform-eo-tests/package.yaml b/pipeline/transform-eo-tests/package.yaml new file mode 100644 index 0000000000..2b5237299c --- /dev/null +++ b/pipeline/transform-eo-tests/package.yaml @@ -0,0 +1,33 @@ +name: transform-eo-tests +version: 0.1.0.0 +github: "value/transform-eo-tests" +license: BSD3 + +# Metadata used when publishing your package +# synopsis: Short description of your package +# category: value + +# To avoid duplicated efforts in documentation and dealing with the +# complications of embedding Haddock markup inside cabal files, it is +# common to point users to the README.md file. +description: Please see the README on GitHub at + +default-extensions: + - ImportQualifiedPost + +ghc-options: + - -Wall + +executables: + transform-eo-tests: + main: Main.hs + source-dirs: app + dependencies: + - base >= 4.7 && < 5 + - yaml + - extra + - filepath + - mtl + - with-utf8 + - text + - optparse-applicative diff --git a/pipeline/transform-eo-tests/transform-eo-tests.cabal b/pipeline/transform-eo-tests/transform-eo-tests.cabal new file mode 100644 index 0000000000..2043732df3 --- /dev/null +++ b/pipeline/transform-eo-tests/transform-eo-tests.cabal @@ -0,0 +1,37 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.36.0. +-- +-- see: https://github.com/sol/hpack + +name: transform-eo-tests +version: 0.1.0.0 +description: Please see the README on GitHub at +homepage: https://github.com/value/transform-eo-tests#readme +bug-reports: https://github.com/value/transform-eo-tests/issues +license: BSD3 +build-type: Simple + +source-repository head + type: git + location: https://github.com/value/transform-eo-tests + +executable transform-eo-tests + main-is: Main.hs + other-modules: + Paths_transform_eo_tests + hs-source-dirs: + app + default-extensions: + ImportQualifiedPost + ghc-options: -Wall + build-depends: + base >=4.7 && <5 + , extra + , filepath + , mtl + , optparse-applicative + , text + , with-utf8 + , yaml + default-language: Haskell2010