Skip to content

Commit

Permalink
Merge branch 'master' into rule-1
Browse files Browse the repository at this point in the history
  • Loading branch information
aabounegm committed Jan 11, 2024
2 parents fdc66c9 + f94c194 commit 1b05862
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 12 deletions.
16 changes: 15 additions & 1 deletion .github/workflows/ghc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,24 @@ jobs:
uses: actions/checkout@v4

- name: 🧰 Setup Stack
uses: freckle/stack-action@v4
# FIXME use freckle/stack-action@v4 when https://github.com/freckle/stack-action/pull/31 is merged
uses: deemp/stack-action@main
with:
fast: ${{ github.ref_name != 'master' }}

- uses: actions/setup-node@v4
with:
node-version: 20

- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: 21

- run: npm install -g [email protected]

- run: ./pipeline.sh

haddock:
needs: [build]
if: ${{ github.ref_name == 'master' }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.eoc
before.txt
after.txt
app.eo
*.bak
eo-phi-normalizer/src/Language/EO/Phi/Syntax/Lex.hs
eo-phi-normalizer/src/Language/EO/Phi/Syntax/Par.hs
Expand Down
38 changes: 34 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 57 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
{
inputs.flakes.url = "github:deemp/flakes";
inputs = {
flakes.url = "github:deemp/flakes";
eoc = {
url = "github:deemp/eoc";
flake = false;
};
# should be synchronized with
# https://github.com/objectionary/eoc/blob/116286a11aa538705c0f2b794abbdbcc6dec33ef/mvnw/.mvn/wrapper/maven-wrapper.properties#L18
maven-wrapper-jar = {
flake = false;
url = "https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar";
};
};
outputs = inputs: inputs.flakes.makeFlake {
inputs = {
inherit (inputs.flakes.all)
haskell-tools codium drv-tools devshell
flakes-tools nixpkgs formatter workflows lima;
haskell-tools drv-tools devshell
flakes-tools nixpkgs formatter
slimlock;
inherit (inputs) eoc maven-wrapper-jar;
};
perSystem = { inputs, system }:
let
Expand All @@ -14,8 +28,9 @@
# --- Imports ---

pkgs = inputs.nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
inherit (inputs.devshell.lib.${system}) mkCommands mkRunCommands mkShell;
inherit (inputs.drv-tools.lib.${system}) withAttrs withMan withDescription mkShellApp man;
inherit (inputs.drv-tools.lib.${system}) mkShellApps;
inherit (inputs.flakes-tools.lib.${system}) mkFlakesTools;
inherit (inputs.haskell-tools.lib.${system}) toolsGHC;

Expand Down Expand Up @@ -69,7 +84,7 @@
packages = ps: [ ps.${packageName} ];
})
hls cabal fourmolu justStaticExecutable
ghcid haskellPackages hpack stack;
ghcid ghc haskellPackages hpack stack;

# --- Tools ---

Expand All @@ -80,6 +95,7 @@
fourmolu
cabal
stack
pkgs.gh
# `cabal` already has a `ghc` on its `PATH`,
# so you may remove `ghc` from this list.
# Then, you can access `ghc` like `cabal exec -- ghc --version`.
Expand All @@ -93,7 +109,30 @@

# --- Packages ---

packages = {
packages = mkShellApps {
eoc = pkgs.buildNpmPackage rec {
name = "";
version = "0.15.1";
src = inputs.eoc;
npmDepsHash = "sha256-j6lfte6RhxRY5cRHcrtIHfZDe0lP1ovEukgHbHsGPb0=";
npmInstallFlags = [ "--omit=dev" ];
dontNpmBuild = true;

postPatch =
let path = "mvnw/.mvn/wrapper/maven-wrapper.jar"; in
''
cp ${inputs.maven-wrapper-jar} ${path}
chmod +x ${path}
'';
meta = with pkgs.lib; {
description = "EO compiler";
homepage = "https://github.com/objectionary/eoc";
license = licenses.mit;
};
};

#

# --- Haskell package ---

# This is a static executable with given runtime dependencies.
Expand All @@ -104,6 +143,17 @@
};

"${packageName}" = haskellPackages."${packageName}";

pipeline = {
runtimeInputs = [ stack pkgs.jdk21 packages.eoc pkgs.maven ];
text = ''
JAVA_HOME="${pkgs.jdk21.home}"
export JAVA_HOME
${builtins.readFile ./pipeline.sh}
'';
description = "Run pipeline";
excludeShellChecks = [ "SC2139" ];
};
};

# --- Devshells ---
Expand All @@ -115,7 +165,7 @@
bash.extra = "export LANG=C.utf8";
commands =
mkCommands "tools" tools
++ mkRunCommands "packages" { inherit (packages) default; }
++ mkRunCommands "packages" { inherit (packages) default pipeline; }
;
};
};
Expand Down
62 changes: 62 additions & 0 deletions pipeline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
mkdir -p pipeline
cd pipeline

shopt -s expand_aliases

EO=0.34.2
alias eo="eoc --parser=${EO}"

cat > app.eo <<EOT
[args] > app
QQ.io.stdout > @
"Hello, world!\n"
EOT

eo clean
eo link
eo --alone dataize app > before.txt

eo phi

# Now, you modify/normalize this file:
IO=".eoc/phi/app.phi"
I=".eoc/phi/app.bk.phi"
mv "$IO" "$I"
stack run normalize-phi < "$I" > "$IO" \
|| {
printf "\n\nNormalizer failed"
printf "\n\n* EO expression:\n\n"
cat app.eo
printf "\n\n* Phi expression:\n\n"
cat "$I"
printf "\n\n* Error:\n\n"
cat "$IO"
exit 1
}

printf "\n\nNormalizer succeeded!\n\n"
printf "\n\n* Phi expression:\n\n"
cat "$I"
printf "\n\n* Normalized Phi expression:\n\n"
cat "$IO"
printf "\n\n* Diff:\n\n"
diff "$I" "$IO"

eo unphi

cp .eoc/unphi/app.xmir .eoc/2-optimize/app.xmir

eo print

cp .eoc/print/app.eo app.eo

eo clean
eo link
eo --alone dataize app > after.txt

if [ "$(cat before.txt)" == "$(cat after.txt)" ]; then
echo 'SUCCESS'
else
echo 'FAILURE'
exit 1
fi

1 comment on commit 1b05862

@0pdd
Copy link

@0pdd 0pdd commented on 1b05862 Jan 11, 2024

Choose a reason for hiding this comment

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

I wasn't able to retrieve PDD puzzles from the code base and submit them to github. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0 && pdd -v -f /tmp/20240111-1632269-m6h55l [1]: + set -e + set -o pipefail + cd /tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0 + pdd...

Please, copy and paste this stack trace to GitHub:

UserError
set -x && set -e && set -o pipefail && cd /tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0 && pdd -v -f /tmp/20240111-1632269-m6h55l [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0
+ pdd -v -f /tmp/20240111-1632269-m6h55l

My version is 0.23.2
Ruby version is 3.1.4 at x86_64-linux
Reading from root dir /tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0
/tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0/.vscode/settings.json is a binary file (48 bytes)
/tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0/flake.lock is a binary file (1494 bytes)
/tmp/0pdd20240111-14-qffsaq/Z2l0QGdpdGh1Yi5jb206b2JqZWN0aW9uYXJ5L25vcm1hbGl6ZXIuZ2l0/renovate.json is a binary file (114 bytes)
Reading .envrc ...
Reading .gitattributes ...
Reading .github/workflows/ghc.yml ...
Reading .gitignore ...
Reading README.md ...
Reading cabal.project ...
Reading eo-phi-normalizer/.gitignore ...
Reading eo-phi-normalizer/CHANGELOG.md ...
Reading eo-phi-normalizer/LICENSE ...
Reading eo-phi-normalizer/README.md ...
Reading eo-phi-normalizer/Setup.hs ...
ERROR: ERROR: eo-phi-normalizer/Setup.hs; PDD::Error at eo-phi-normalizer/Setup.hs:28: TODO found, but puzzle can't be parsed, most probably because TODO is not followed by a puzzle marker, as this page explains: https://github.com/cqfn/pdd#how-to-format
If you can't understand the cause of this issue or you don't know how to fix it, please submit a GitHub issue, we will try to help you: https://github.com/cqfn/pdd/issues. This tool is still in its beta version and we will appreciate your feedback. Here is where you can find more documentation: https://github.com/cqfn/pdd/blob/master/README.md.
Exit code is 1

/app/objects/git_repo.rb:73:in `rescue in block in xml'
/app/objects/git_repo.rb:70:in `block in xml'
/app/vendor/ruby-3.1.4/lib/ruby/3.1.0/tempfile.rb:317:in `open'
/app/objects/git_repo.rb:69:in `xml'
/app/objects/puzzles.rb:41:in `deploy'
/app/objects/jobs/job.rb:38:in `proceed'
/app/objects/jobs/job_starred.rb:32:in `proceed'
/app/objects/jobs/job_recorded.rb:31:in `proceed'
/app/objects/jobs/job_emailed.rb:33:in `proceed'
/app/objects/jobs/job_commiterrors.rb:33:in `proceed'
/app/objects/jobs/job_detached.rb:48:in `exclusive'
/app/objects/jobs/job_detached.rb:36:in `block in proceed'
/app/objects/jobs/job_detached.rb:36:in `fork'
/app/objects/jobs/job_detached.rb:36:in `proceed'
/app/0pdd.rb:531:in `process_request'
/app/0pdd.rb:367:in `block in <top (required)>'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1706:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1706:in `block in compile!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1019:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1037:in `route_eval'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1019:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1068:in `block in process_route'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1066:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1066:in `process_route'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1017:in `block in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1014:in `each'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1014:in `route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1138:in `block in dispatch!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `invoke'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1133:in `dispatch!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:949:in `block in call!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `invoke'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:949:in `call!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:938:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/deflater.rb:44:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/xss_header.rb:20:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/path_traversal.rb:18:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/json_csrf.rb:28:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/base.rb:53:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/base.rb:53:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/frame_options.rb:33:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/logger.rb:17:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/common_logger.rb:38:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:261:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:254:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/method_override.rb:24:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:219:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:2018:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1576:in `block in call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1792:in `synchronize'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1576:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/handler/webrick.rb:95:in `service'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb:140:in `service'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb:96:in `run'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/server.rb:310:in `block in start_thread'

Please sign in to comment.