Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed 'play idea' now is correctly for WSL Run GitHub Action on win and fixed test for Windows #1382

Merged
merged 7 commits into from
Mar 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ concurrency:
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
testing:
runs-on: ${{ matrix.os }}

strategy:
matrix:
jdk: [ 11, 17 ]
name: Check / Tests (JDK ${{ matrix.jdk }})
os: [ubuntu-latest, windows-latest]
exclude:
- os: windows-latest
jdk: 11

name: Check / Tests -> JDK-${{ matrix.jdk }}/${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -39,3 +44,39 @@ jobs:
- name: Build with Ant
working-directory: ./framework
run: ant test

build:
needs:
- testing
runs-on: ubuntu-latest
name: BUILD ${{ github.sha }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
# we don't know what commit the last tag was it's safer to get entire repo so previousStableVersion resolves
fetch-depth: 0

- name: Set up python 2
uses: actions/setup-python@v2
with:
python-version: '2.x'
architecture: 'x64'

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 17
distribution: 'adopt'

- name: Build with Ant
working-directory: ./framework
run: ant artifact

- name: ziping artifact
uses: actions/upload-artifact@v2
with:
name: play-${{ github.sha }}
if-no-files-found: error
path: |
./framework/dist/*
16 changes: 12 additions & 4 deletions framework/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -420,13 +420,21 @@
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</target>

<target name="package" depends="clean,version,jar,javadoc">
<target name="package" depends="artifact">
<mkdir dir="dist" />
<zip destfile="dist/play-${version}.zip" comment="Play! ${version}" update="false">
<zipfileset prefix="play-${version}" dir=".." includes="**/*" excludes="**/cobertura.ser,**/*.pyc,hs_err*,.*,.*/*,framework/dist/**,id,play,nbproject/**,**/.bzr/**,**/.git/**,*.bzrignore,support/textmate/**,framework/classes/**,framework/tests-results/**,samples-and-tests/**/test-result,samples-and-tests/**/i-am-working-here,samples-and-tests/**/data,samples-and-tests/**/logs,samples-and-tests/**/tmp,samples-and-tests/**/db,samples-and-tests/**/attachments,modules/**" />
<zipfileset prefix="play-${version}" dir=".." includes="play" filemode="777" />
<zipfileset prefix="play-${version}" dir=".." includes="modules/grizzly/**,modules/crud/**,modules/secure/**,modules/docviewer/**,modules/testrunner/**" excludes="**/*.pyc" />
<zipfileset prefix="play-${version}" dir="dist/play-${version}" includes="**/*" excludes="play" />
<zipfileset prefix="play-${version}" dir="dist/play-${version}" includes="play" filemode="777" />
</zip>
</target>

<target name="artifact" depends="clean,version,jar,javadoc">
<mkdir dir="dist" />
<mkdir dir="dist/play-${version}" />
<copy todir="dist/play-${version}">
<fileset dir=".." excludes=".github,**/cobertura.ser,**/*.pyc,hs_err*,.*,.*/*,framework/dist/**,id,nbproject/**,**/.bzr/**,**/.git/**,*.bzrignore,support/textmate/**,framework/classes/**,framework/tests-results/**,samples-and-tests/**/test-result,samples-and-tests/**/i-am-working-here,samples-and-tests/**/data,samples-and-tests/**/logs,samples-and-tests/**/tmp,samples-and-tests/**/db,samples-and-tests/**/attachments,modules/**" />
<fileset dir=".." includes="modules/grizzly/**,modules/crud/**,modules/secure/**,modules/docviewer/**,modules/testrunner/**" excludes="**/*.pyc" />
</copy>
</target>

</project>
12 changes: 8 additions & 4 deletions framework/pym/play/commands/intellij.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def execute(**kargs):
shutil.copyfile(os.path.join(play_env["basedir"], 'resources/idea/imlTemplate.xml'), imlFile)
cpXML = ""

playHome = play_env["basedir"].replace('\\', '/')
Copy link
Contributor

Choose a reason for hiding this comment

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

Causes #1399

playHomeAlternative = app.toRelative(playHome).replace('\\', '/')
if playHomeAlternative[0:2] == "..":
playHome = "$MODULE_DIR$/" + playHomeAlternative

if os.name == 'nt':
# On Windows, IntelliJ needs uppercase driveletter
Expand All @@ -44,7 +46,9 @@ def execute(**kargs):
for i, module in enumerate(modules):
libpath = os.path.join(module, 'lib')
srcpath = os.path.join(module, 'src')
lXML += ' <content url="file://%s">\n <sourceFolder url="file://%s" isTestSource="false" />\n </content>\n' % (module, os.path.join(module, 'app').replace('\\', '/'))
path = app.toRelative(module).replace('\\', '/')
modulePath = "$MODULE_DIR$/" + path if path[0:2]==".." else module
lXML += ' <content url="file://%s">\n <sourceFolder url="file://%s" isTestSource="false" />\n </content>\n' % (modulePath, os.path.join(modulePath, 'app').replace('\\', '/'))
if os.path.exists(srcpath):
msXML += ' <root url="file://$MODULE_DIR$/%s"/>\n' % (app.toRelative(srcpath).replace('\\', '/'))
if os.path.exists(libpath):
Expand All @@ -54,13 +58,13 @@ def execute(**kargs):
replaceAll(imlFile, r'%MODULE_LINKS%', mlXML)
replaceAll(imlFile, r'%MODULE_SOURCES%', msXML)
replaceAll(imlFile, r'%MODULE_LIBRARIES%', jdXML)

iprFile = os.path.join(app.path, application_name + '.ipr')
# Only copy/create if missing to avoid overwriting customizations
if not os.path.exists(iprFile):
shutil.copyfile(os.path.join(play_env["basedir"], 'resources/idea/iprTemplate.xml'), iprFile)
replaceAll(iprFile, r'%PROJECT_NAME%', application_name)


print "~ OK, the application is ready for Intellij Idea"
print "~ Use File, Open Project... to open \"" + application_name + ".ipr\""
Expand Down
98 changes: 39 additions & 59 deletions framework/test-src/play/templates/FastTagsTest.java
Original file line number Diff line number Diff line change
@@ -1,62 +1,50 @@
package play.templates;

import groovy.lang.Closure;
import org.junit.After;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;

import groovy.lang.Closure;
import play.mvc.Http;
import play.mvc.Router;
import play.mvc.Scope;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;

public class FastTagsTest {

private static final String LINE_SEPARATOR = System.lineSeparator();
private StringWriter out = new StringWriter();
final String backupSystemLineBreak = System.getProperty("line.separator");

@Before
public void setUp() throws Exception {
//if you render html into out
// and expect results with line breaks
// take into account that your tests will fail on other platforms
// force line.separator be the same on any platform
// or use String.format in expected code with the placeholder '%n' for any expected line separation.
System.setProperty("line.separator","\n");

Http.Response.current.set(new Http.Response());
Http.Response.current().encoding = "UTF-8";

Scope.Session.current.set(new Scope.Session());
Scope.Session.current().put("___AT", "1234");
}
@After
public void tearDown() throws Exception {
// restore line.separator
System.setProperty("line.separator", backupSystemLineBreak);
}

@Test
public void _form_simple() throws Exception {
final Router.ActionDefinition actionDefinition = new Router.ActionDefinition();
actionDefinition.url = "/foo/bar";
actionDefinition.method = "GET";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >" + LINE_SEPARATOR
+ LINE_SEPARATOR + "</form>", out.toString());
}

@Test
Expand All @@ -65,17 +53,16 @@ public void _form_withName() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.method = "GET";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
put("name", "my-form");
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" name=\"my-form\">\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" name=\"my-form\">"
+ LINE_SEPARATOR + LINE_SEPARATOR + "</form>", out.toString());
}

@Test
Expand All @@ -84,17 +71,16 @@ public void _form_post() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.method = "POST";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >\n" +
"<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >" + LINE_SEPARATOR
+ "<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>" + LINE_SEPARATOR + LINE_SEPARATOR + "</form>",
out.toString());
}

@Test
Expand All @@ -103,17 +89,16 @@ public void _form_starIsPost() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.star = true;

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >\n" +
"<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >" + LINE_SEPARATOR
+ "<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>" + LINE_SEPARATOR + LINE_SEPARATOR + "</form>",
out.toString());
}

@Test
Expand All @@ -122,18 +107,17 @@ public void _form_argMethodOverridesActionDefinitionMethod() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.method = "GET";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
put("method", "POST");
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >\n" +
"<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >" + LINE_SEPARATOR
+ "<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>" + LINE_SEPARATOR + LINE_SEPARATOR + "</form>",
out.toString());
}

@Test
Expand All @@ -142,17 +126,16 @@ public void _form_customArgs() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.method = "GET";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
put("data-customer", "12");
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" data-customer=\"12\" >\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" data-customer=\"12\" >"
+ LINE_SEPARATOR + LINE_SEPARATOR + "</form>", out.toString());
}

@Test
Expand All @@ -161,16 +144,15 @@ public void _form_actionAsActionArg() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.method = "GET";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("action", actionDefinition);
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >" + LINE_SEPARATOR
+ LINE_SEPARATOR + "</form>", out.toString());
}

@Test
Expand All @@ -179,31 +161,29 @@ public void _form_customEnctype() throws Exception {
actionDefinition.url = "/foo/bar";
actionDefinition.method = "GET";

Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", actionDefinition);
put("enctype", "xyz");
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"xyz\" >\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"get\" accept-charset=\"UTF-8\" enctype=\"xyz\" >" + LINE_SEPARATOR + LINE_SEPARATOR + "</form>",
out.toString());
}

@Test
public void _form_argAsUrlInsteadOfActionDefinition() throws Exception {
Map<String, ?> args = new HashMap<String, Object>() {{
Map<String, ?> args = new HashMap<>() {{
put("arg", "/foo/bar");
}};

FastTags._form(args, mock(Closure.class), new PrintWriter(out), null, 0);

assertEquals(
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >\n" +
"<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>\n" +
"\n" +
"</form>", out.toString());
"<form action=\"/foo/bar\" method=\"post\" accept-charset=\"UTF-8\" enctype=\"application/x-www-form-urlencoded\" >" + LINE_SEPARATOR
+ "<input type=\"hidden\" name=\"authenticityToken\" value=\"1234\"/>" + LINE_SEPARATOR + LINE_SEPARATOR + "</form>",
out.toString());
}
}