From 34e00da79510acc986934725e051c3337a1594f8 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 24 Sep 2020 13:32:23 -0700 Subject: [PATCH 01/64] Update Bazel CI workflow Build all Oppia targets in Bazel rather than just the binary target. --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30a44cade99..aca1c0c2561 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -133,7 +133,7 @@ jobs: path: app/build/reports bazel_build_app: - name: Build Binary with Bazel + name: Build Oppia targets with Bazel runs-on: ${{ matrix.os }} strategy: matrix: @@ -150,19 +150,19 @@ jobs: uses: actions/setup-java@v1 with: java-version: 9 - - name: Extract Android Tools + - name: Extract Android tools run: | mkdir -p $GITHUB_WORKSPACE/tmp/android_tools cd $HOME/oppia-bazel unzip bazel-tools.zip tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools - - name: Unzip Bazel Binary and Build Oppia + - name: Unzip Bazel binary and build all Oppia targets run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build //:oppia --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx + $HOME/oppia-bazel/bazel build //... --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - uses: actions/upload-artifact@v2 with: From 3f0cd724d77bf25bfe053e7d1e14ad9dfe67c419 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 24 Sep 2020 13:35:47 -0700 Subject: [PATCH 02/64] Update main.yml Reset the workflow name so that it doesn't need to be renamed in GitHub settings. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index aca1c0c2561..f4440b323c0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -133,7 +133,7 @@ jobs: path: app/build/reports bazel_build_app: - name: Build Oppia targets with Bazel + name: Build Binary with Bazel runs-on: ${{ matrix.os }} strategy: matrix: From 5c92f2ccd9f5f3d14cd08c7cce160fb1d9b75cd9 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 13:56:59 -0800 Subject: [PATCH 03/64] Introduce remote caching in Bazel. This uses a remote storage service with a local file encrypted using git-secret to act as the authentication key for Bazel to read & write artifacts to the service for caching purposes. --- .github/workflows/main.yml | 22 ++++++++++++++++-- .gitignore | 3 +++ .gitsecret/keys/pubring.kbx | Bin 0 -> 3939 bytes .gitsecret/keys/pubring.kbx~ | Bin 0 -> 1980 bytes .gitsecret/keys/trustdb.gpg | Bin 0 -> 1200 bytes .gitsecret/paths/mapping.cfg | 1 + ...kflow-remote-cache-credentials.json.secret | Bin 0 -> 2543 bytes 7 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 .gitsecret/keys/pubring.kbx create mode 100644 .gitsecret/keys/pubring.kbx~ create mode 100644 .gitsecret/keys/trustdb.gpg create mode 100644 .gitsecret/paths/mapping.cfg create mode 100644 config/oppia-dev-workflow-remote-cache-credentials.json.secret diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8df24103d0..89a66d3f9db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -140,7 +140,7 @@ jobs: os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 - - name: Set up bazel + - name: Set up Bazel uses: jwlawson/actions-setup-bazel@v1 with: bazel-version: '3.4.1' @@ -156,13 +156,31 @@ jobs: cd $HOME/oppia-bazel unzip bazel-tools.zip tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools + - name: Install git-secret (https://git-secret.io/installation) + run: | + cd $HOME + git clone https://github.com/sobolevn/git-secret.git git-secret + cd git-secret && make build + PREFIX="$HOME/gitsecret" make install + - name: Decrypt secrets + env: + GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} + run: | + cd $HOME + # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! + echo $GIT_SECRET_GPG_PRIVATE_KEY > ./git_secret_private_key.gpg + gpg --import ./git_secret_private_key.gpg + cd $GITHUB_WORKSPACE + git secret reveal - name: Unzip Bazel binary and build all Oppia targets + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build //... --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx + $HOME/oppia-bazel/bazel build --keep_going --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //... cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - uses: actions/upload-artifact@v2 with: diff --git a/.gitignore b/.gitignore index 76abf6584c3..67dfc7158ef 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,6 @@ utility/build gradle gradlew gradlew.bat +.gitsecret/keys/random_seed +!*.secret +config/oppia-dev-workflow-remote-cache-credentials.json diff --git a/.gitsecret/keys/pubring.kbx b/.gitsecret/keys/pubring.kbx new file mode 100644 index 0000000000000000000000000000000000000000..8727b699585657656d91e6509e24e6007522b945 GIT binary patch literal 3939 zcma)-1yodRx5v*6;7|es(lvyXfTXkxNOuY{C=5dlF*K6WC5?o{yo3VMNJy7-h=eE# zh_sXn11kN2Ue|rs{oZ@O`>b`&v(J9^IqR&o|Ns31000I80borfE+r>4y!K)|f_!N2@K2Iz z!wI@<7{?iJwR9YivK6?iJ%-Xp)f*xPpM=Lti1JU-08YcD>#cW3N-1Az<#{b>BfJ$lh_~d$iuiQ=Vs`P$Dk5rZUuaTv9B*pIo?9 zWn2N#Ah~SkI%i!%EFWEP09Lr=wzS&>c19~p#r%rhwf4c2HjB%KHv~hPjn37s%So9;IZ3*KwI%wA)zIeAcQ z^DIvw^S9^+t+bzvu&aE2X(Oe4%q|LkjpH-j`yv^R_RfnoJ~;ea$dZq6Om7h>>vR+t z2?zIu*C7vxbo0KyP_Dq?`Z>{`xJTs)X_Gl@HcID0l%D2wQE*M;3SC)#x-<$g@fv8o z>j{k#osU(rb1$!}_9nfxx?~{zVa7QN#>N&I#^2LCmta1hd);EM^&QRoQE%Q3d>IFu z^vKTR)$u?}Q3+PMwticxV_h&nVm58&y1G!6I?ZRA6(8ZcUoq?BkV8i88^<MV zi!qi1dZFjFh9;NaQ|#R7MTI2?+pm7zbdaE zh}Ua3m~VJb;uU*+8?&6-`g`SVJ3E^Gw;7A{yi|0)Tuu;tiA{C4h_+)Jh zM_~*v_?uO(9%qpbTfijfDXL=N+x47V!C{H(9kUZzO&&x|J6uEBn}sKHnnC3WJ+Wcs zj9}gm!GT8WAv%$Kr)CHCi5$b@KUpS@%gK9GYhU-U`Lvq)wwqeBQitwHYQdS_hRj?NK zb`0i!Ac~GA(NTYie(uYw8d0mJSM>6F9<=P!GRZ*d%8q;B-({rAj{GEv()lJ+82v!e zyQt0U3F#}jQA?;#P#+;~bf}!{eyK;S-%V;s@6rn6XDtSs@|o_L+g8)oJQMM!1ak$2 z_w89AwKpo~Uz3>>ybApRCp%r(cTnU+Z~n4u45$^K?%Zx%|G{pgzwP#STV)iIoU#@6 zCe<_Qkr_Dimtr%JmT~hv4rS1r< zIfosbbB(eAZ@EHdhMUdjSg)_OtnKbM*r}3EQ9QW{>ZSVB0$l>#K?S5EID}QwX?(0| z)|W=XaYbRb{7jp(hC-`;$)kg*I3HB40V8kcesKNidKE(b6D@+0J)99jKjz>=QY2kC zsIg?kObw~{S+zT&<4c==YXVS+n~-V)+N zy-k}t9%M3DQTsZSA;X6gZ>6A<-w*GC20v}W%|lxABiX~bgP>_|-v%sccaM6t2}$)q z9ThmRU-OEQj}9~9EaB4=!|Y3pZpFwa&b-^n{Fi#HEiccgPjvmX9avrRhfh$Ne2Zd# z-l#ll{Lx&@zYb)S7IyuLTk1rMq!e$u$s+22CNaUhV8_$MhA{eso7{o_^Q|)f=n##w zH-?zTPn9BCr#l%PuToX5p~V>9&yn+>CB zJsYe}3L83$QN7t402SNdwez_PyO_PpS_dMZ?HTfGSnf}%?lH02DL#L3p8j_>3tv>9 zf9-!^^W!@g$G_Q}0zGH*^LD+d!&7)Z`SiP=*EBnMqEUi@BV6MUSuK-I8NFvSR9<~4 zQHQ)KA)kqE3cVdt5+y>Kgx3J+!&=N^h)o6U$EWw)US%gUUWcW`j#pu3v!YJslTGZs zal!%-EdG}gR(3$Mlhg*R&_%Ucv7@Ahk8iexh0=mZV(1!ffpMm`D185SaHB+Z1s7`tYXOspSk#A6}l$wEqRbTbce6lS`(#iG3v4J z)xLQp^Xx4D#1uq2&hgGGV9jSZph9E{Bs12_%J6(rd8WYizh#6EvFg&_>F)PAi%+5%17AWZQ*cLq9D2 zl_vL(D1?)!ZPwwvFdf4Q$Sh%=3R|F@YS-?{l9Aa$u7&^KB7bmuum{cN0n^aiDWWbs@* zA!)cS4=k4>y17Rj$`?QIXP*4V^e^`|b>0#ja=vpq)t}W2?Q|6suNct2d_&@yl>WC5 zl*x(eiR+nTR=3Bg3}a~W8T3BT8MZhdBRmU*tDP-OarfJsR(5&4%FG^>WaE=|tq^4|Gc0`6noRS_S z%@uAYzhK6Xcg!#RfN(+!riCh*dr{Y*TiKVzNQGnx7$Tf~2;Eqm)E%mhkuq^HE>7;Y z4t=8B_ofE`CEDjYvxtGU$#1S*AK^b4@xA}uoJ*e6H0wrLFhim4%t1JiPwYNq>^8L5 z;pJOM;$9jFCo-$#$0gnu+q(MQECKo15VJR(jOv?aq#lyC#WRRD4bVrA6;j1FkSxbE z^Hk_Tcd?HHak;aZh~#xm0l91+BLhT1{$5}>(TCW=$mWxjYV)IgCRdf{Avu5l>Z=c_ z3?M4pksGlk@#zs^?AJDf9|?I#iR}0I8Bwa>e;*B9UGr{xMPY`33!6UqH%$LucKaKq z|JaJXndHpS;x>|xzkUC!@+AjER3&f5wd*5d46}`WjI8AmDjs*e!F%FZE5QE@Cbh3# z6ZlkJ&tLOdXegJc(UrWKM;iSZMk%*hGI|IPgmjaZJ>0#xbor}B8Wc*mwB>QJqKP+# zpQ%lwlPTlLs&OyZ5{fFQrFP64K?BgL91fzUYeW57YhtCxqFv1@B0RP0b6>x}&FHO= zpFOJM0Pln7UKJzAm!f-OJZ>J6@bJCAsyd#wi!&Gb#Ek8f)im9U3D`fmHS4HNW6L$D zyU5PKE0gk5|A#5pY1?vFRCc|lmwWC}4o9s9YBfx^YJcc6>qmj9%THo#t1J&ZXfv@? z((6J+b--4SyXxJ2n=X8$1EsWAp71n0^1jYz!(MKy@QQ*wtDjB_!6;*s5);l~_vM+9|j6RjLtdN|lN|cGp%dbuGEJqSSg( zJ9TTRrIxg|hT8QiUXiP)&_}(_d-LYa+~3SO=X=iiotZQ9{eA!dK!891_$OUEXW*!A z)g{{=yZ0E z1EW2f8@KJC$8!I^y8Y3y*74m@fdDQ50E-F8@}QcjRD0H73*X?6l(R5N=T(-rw35xUuuT)3q+I9l zm#zvMBT3ujSbhg1rMmk>7t_*o1qV0Z2X3aJF78WTV$DAso_!Y1$1bDY_}pnd;bA-~ zKs!>sA|ao>mq+X6id1bIa(Zv%HMtCC8l}JEnxts{a+jycU z&L2bY#JPGXI^FfW{O?!b6O-dW?;rvo4&bs767v6�)-m94x}b%+B-&0bu52XJZAk z2y(Eqae^U2U?vb)31jtlsWFYh^{q2mCm!rN-LK@?*eV#?^Uk(t&3 z#Wziz4Tf*ThO`LJT2q$g1JVXc<>7a+0SzOxSKH^)-CaEA@&0s(95=4a|aqRCITs)9^&RwMgf z42$i-l&fp3Y)?%JZ0}sw*i;}y7FBEs&Z&*vFsqPt7~Dh6y&e$8rGsHzLBVy>Iu^l9 zU4-5|tAC*1NYu5$wY^s+4b}++p`Nkyd6=94lq6H&tvk6Rq0+@LK0sBm08B^G02=>; zY?kaNu@c01?0u(&amSf!K!H)ir(z9?V)jefKvJiA^9Am0*!YJADIC^1NnXpja1e3k z1*++aG$WI%{}uubWq&l69LP; z4-2+lA)7|aAKut=NtWy%*%hNQ%6K{rYlb?J{w;Q-HoH6G0v9eBguF^T?Tg29IBilX zn+ZAkfKimimiJuCeIynolU)7U!W{kBKI$MSZUlStW2(ywReXhlHS=;b2f9Sg!{ut) zAl+VzzZ|!=L?NGhyE(!zj;U$uQB>v$?X`SFBIeF>pw~_+316PW!w)+ec}Ty3#$2*mfJjQwp`W8xRByI-;s?2wLqXpxXJttZd@n0{Wn(Wg`9`T!mfvPBIewd zZ-0*?Lf{uAiyj>&rBF!yQ?4%91Yz3D*2L)iY3Oa0g~b-4FbMiEPg?&~6vaW3fRXyh zU(d8yu1S+c`ZLVCTb{Sx+&~=an-(SVTygs2>gXIa3A$I#+8#z0SMwMduACwXVcnOo zTV>x&q<-hUR=42OE?S%isxn6Kw8@4jJzc4^zd9>y&o2=v!U`L9^XDwmDC{*}u!ak= zmhV<>4VaRI^Yo|yHu|h!vg)`-={u4!oI+MqS|lj~?)mx~4q+Vhb-+XFIZkFYIX}eTKCqFIpl}Hk2=IY%FNOv+Apyn;$4g@@RVCmL9uk+aXdx4O6}Nne!aX9h@tY^Zp27bHyBLWd~moB zSPQaFi%>f4ol0$1QJO{}zRC&h($ literal 0 HcmV?d00001 diff --git a/.gitsecret/keys/trustdb.gpg b/.gitsecret/keys/trustdb.gpg new file mode 100644 index 0000000000000000000000000000000000000000..59fe4e06e4007254bfb5639d1d9a827cca7f6d07 GIT binary patch literal 1200 zcmZQfFGy!*W@Ke#Vql2h+8@Dy9WZiX7sn7CRfiEIV1dza84VXu2#lr!%F+P<`kw@C literal 0 HcmV?d00001 diff --git a/.gitsecret/paths/mapping.cfg b/.gitsecret/paths/mapping.cfg new file mode 100644 index 00000000000..75e37c7661f --- /dev/null +++ b/.gitsecret/paths/mapping.cfg @@ -0,0 +1 @@ +config/oppia-dev-workflow-remote-cache-credentials.json:c02f95d3829f9a7fb3757170ade432efa43d562d2e7c208372ec9d0f4a45da1a diff --git a/config/oppia-dev-workflow-remote-cache-credentials.json.secret b/config/oppia-dev-workflow-remote-cache-credentials.json.secret new file mode 100644 index 0000000000000000000000000000000000000000..2aa2fc7d0fe832b376a6de32720cbed7b693f5c1 GIT binary patch literal 2543 zcmVfsGYESfYsGx^4f<dnr7f&kVoFz3Ip;+Avv2bP&gODT(wWd;UJd)AYoRAJCrT4zxlrc%q zQ2lI8Rge-o!N&MhLj-#N$WQ3(`ejuxGs>;xI@neU=D$vv`%$?pyAx_tbpEVG{VGUc z9dU+T;^Lq!cD_8Q0VZSU6y3e$2`0OEL`uQT`+M`K$S#m z3`WDEHc_gpsO{aE8nPJsz%Vu|45hh~iLT&PAx83vFBV+#AK{SROMdgqi;a=N`FI`6 z?{p%=tl1LeLw%~3J#4rg{+Gbf0>57+)Ego>8njLBf%=!FuMw8>(1ihv14r~6A7?_b zwgC(PxhUKDL#hl(z_}2_27PQYRjCgFMt^<+0x9mx;#vZ)>JQRhgunz;|M&0tbE#aW zI&e23Alh?9yMg(nLp@W#fHH@4}mR(dkF5@t%K3xfM*J#jE&zGHN9SWtIP3idwg~S z-o6S?sNys63J0N*=QEX_(Nzz+*sFD(F+of0n;>;T2X9LXcQZT^q7)}T6ZL9M!QKj8X(BdE!QEv{NzlcWcvi5fElqH0s1T5@v2rM-@kZ zys+%}w+H=-|BAP-LkvHwGLEK-y3mH5+q8HH%N z$JDrpRf$`WJ=LJN+s$#g0?Gr)b5qn#H;<0mnWr@yb%xF=o#Rx~$E#`oIyF%Xm$UVG zhU2M?Pl`s3i=KyK_+f1B#OW#b_!g;0`(8>iLOu$c10HAT%D9djZ#SttUt^T&;4_>%lZFX{ zach>;)m_t?Bw zLWEBAwo>_$TPP8bVW?7Ad0rvh5mYaQhq>cs{k+=8)92qIc>Zi|W{l)myDs9HY5Sa# zlUm4?Z!!T*$nW;@Vs!PWJrBwpA?9=R5~|jcQ-oTz!!%zeZncqYZoRxqVCKEb z1XWn0fjU&2$48{Jx=l; zvrPp+hywGG(kVe|`QanD5S18ECSP~o4@?_l3 zmMZzs5RE8~SBV>c&Pp87=jGZla?LU!y&5#M_%peCzuaRr(l#s|q~#xd;u6;V&bov% z=|}H^w0UD~`EE{-s-8xvo}-^_!fR%SpJnVjCuv_@FIPw4WN@l5nz7zdCej+8DaR%F z0)0PpAy*1X=WR_x{OzHSfN9aG;L%}bH^!Y^xcztil205s~%ny(|dxwE5y-t;{Zu*1p#uizC=a*fASpEUbej{y5SW=o3iUA27CQ< zh0Ls70?!gNgB~MLQ>aY~p0yfeHtfSaAV^v=;29kD`?{ac{v6Oa$h~uM)1fT`tZ#BO zurI)U>isXt$D}ZNmxuJ{?MkFae4%it?)jWd_Q3vT3P zO~k}5%8+LlrDtsi|Hg1u6ZybQ5{~28fLuI-B1u*_-tB>VJJo|T1)Y+hH}7)n6Hn9s zp^aZfXA&nIGlao!xu^A8v>;Z9FXg*N2=JwBt~{{mE+LL?T9jn=#M(V&CDOyDad3yK zRe9o~P$9Bb#LCZ(PFkW}-X2ifv}9-i)_YqQ1$*N?EBkEchjWy_%VQaT-2)@BaNg;} z;Zw-A8Dyv77jJtelYZJEi0{h|%MvGSnVPMNUo-71Gn1|~zMSSSKeino9Vn|HRlp~% zE8Ca}Xneq6s&=QFE5Q*aJ9L&j4b*f!J-Ph5e`-HIXq1!Cr=zg4j#=3SfNN!ITUes0 z-n{?3IZi_goChJRLFxzmho`ig#AGo{=rn|AQO~jd;5(UufL7};;h&b#i=pzcAlwAR z)JCT7elLN#h~1vs0O|lAuf)i{_#2R{%eYR0;?X#G9o-#409)S{20h4Jf-hQ0LonEg zr8fFR5B~Z@-@A#fFt61v%?H%;=qJOfwm%P0x3R8t}4QdEQu8bM?u;S+*;BMR1 zRC0^J4L`WIgarxFRz_%g##>wOr*IfC%^Zj*3d{ft>}LP92xP^gvhTj6BE84Vh4dAx zn?wvIrpgVgU}E}51I`VOZz2^ULW;wObf0#lWX%jA>a{^l8ot(&YdK@U7m=Y;^Z z=YZ|<6=c-`z}Zq=#O!s*Yhqh34fBy0ReMkFYxh117QELD0QV0~haab%{1N~iJ^j=~ z^Ng{HeH8xm?||MlNYE$QiV)tMTil<1fJS1YP)oe&O3k FFt=NW{1X5G literal 0 HcmV?d00001 From 9d026e98995c9517d60644e31ef6c139e6f26810 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:02:13 -0800 Subject: [PATCH 04/64] Add debug line. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89a66d3f9db..b224f031fca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -170,6 +170,7 @@ jobs: # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! echo $GIT_SECRET_GPG_PRIVATE_KEY > ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg + wc -c ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - name: Unzip Bazel binary and build all Oppia targets From 4ac50c6e23fd729012672c7a03d49064ee191eb1 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:04:24 -0800 Subject: [PATCH 05/64] Disable workflows + fix debug line. --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b224f031fca..17c8258ba7e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,7 @@ on: jobs: linters: name: Lint Tests + if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -47,6 +48,7 @@ jobs: robolectric_tests: name: Robolectric Tests (Non-App Modules) + if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -104,6 +106,7 @@ jobs: app_tests: name: Robolectric Tests - App Module (Non-Flaky) + if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -169,8 +172,8 @@ jobs: cd $HOME # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! echo $GIT_SECRET_GPG_PRIVATE_KEY > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg wc -c ./git_secret_private_key.gpg + gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - name: Unzip Bazel binary and build all Oppia targets From 93c3608ccfef97acf12a58de30008fd52f1bebe2 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:12:58 -0800 Subject: [PATCH 06/64] More debugging. --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 17c8258ba7e..3ef0a29d8fc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -173,6 +173,7 @@ jobs: # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! echo $GIT_SECRET_GPG_PRIVATE_KEY > ./git_secret_private_key.gpg wc -c ./git_secret_private_key.gpg + sha1sum ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal From 4df788f405159ba1da253fd716629dfa9f978fe4 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:17:35 -0800 Subject: [PATCH 07/64] More debugging. --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3ef0a29d8fc..c426fa8079b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -167,13 +167,15 @@ jobs: PREFIX="$HOME/gitsecret" make install - name: Decrypt secrets env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} + TEST_GPG_KEY: ${{ secrets.TEST_GPG_KEY }} + #GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} run: | cd $HOME # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY > ./git_secret_private_key.gpg + echo $TEST_GPG_KEY > ./git_secret_private_key.gpg wc -c ./git_secret_private_key.gpg sha1sum ./git_secret_private_key.gpg + echo $TEST_GPG_KEY gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal From b29282684370bfb9e1c77cda52512d156c0bde77 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:19:57 -0800 Subject: [PATCH 08/64] Work around GitHub hiding secret since we're debugging. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c426fa8079b..1ca80c27f46 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -175,7 +175,7 @@ jobs: echo $TEST_GPG_KEY > ./git_secret_private_key.gpg wc -c ./git_secret_private_key.gpg sha1sum ./git_secret_private_key.gpg - echo $TEST_GPG_KEY + cat ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal From 5bbc72a37c91c2e035ada562a5b236fb1a1caf86 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:34:14 -0800 Subject: [PATCH 09/64] Use base64 to properly encode newlines in GPG keys. --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1ca80c27f46..cb9a8557f50 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -172,8 +172,7 @@ jobs: run: | cd $HOME # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $TEST_GPG_KEY > ./git_secret_private_key.gpg - wc -c ./git_secret_private_key.gpg + echo $TEST_GPG_KEY | base64 --decode > ./git_secret_private_key.gpg sha1sum ./git_secret_private_key.gpg cat ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg From c9b9d0b32c664894e64e98d079179fca514e1211 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:38:30 -0800 Subject: [PATCH 10/64] Remove debug lines before changing back to correct GPG key. --- .github/workflows/main.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cb9a8557f50..98101b72d40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -173,8 +173,6 @@ jobs: cd $HOME # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! echo $TEST_GPG_KEY | base64 --decode > ./git_secret_private_key.gpg - sha1sum ./git_secret_private_key.gpg - cat ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal From ca3fadc0792a94a92b68ba8456746b5bdb58f40f Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:41:13 -0800 Subject: [PATCH 11/64] Switch to production key. --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 98101b72d40..8ca96b0359b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -167,12 +167,11 @@ jobs: PREFIX="$HOME/gitsecret" make install - name: Decrypt secrets env: - TEST_GPG_KEY: ${{ secrets.TEST_GPG_KEY }} - #GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} + GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} run: | cd $HOME # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $TEST_GPG_KEY | base64 --decode > ./git_secret_private_key.gpg + echo GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal From 7854318605e61a68f9a3b18c75cc98f43e81a69d Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:43:06 -0800 Subject: [PATCH 12/64] Fix env variable reference. Lock-down actions workflows via codeowners. --- .github/CODEOWNERS | 3 +++ .github/workflows/main.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1b33b4c5b3c..dd191a30d42 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,6 +11,9 @@ # (See oppia/#10250 for an example.) Please make sure to restore ownership after # the above date passes. +# GitHub Actions & CI workflows. +.github/main.yaml @BenHenning + # Blanket codeowners # This is for the case when new files are created in any directories that aren't # covered as a whole, since in these cases, codeowners are not recognized for diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8ca96b0359b..249e75755fe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -171,7 +171,7 @@ jobs: run: | cd $HOME # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg + echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal From 74a775b367ff9d9a1678d5edab766f4f81053069 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:45:47 -0800 Subject: [PATCH 13/64] Install git-secret to default location. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 249e75755fe..a2dcdfcbabe 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: cd $HOME git clone https://github.com/sobolevn/git-secret.git git-secret cd git-secret && make build - PREFIX="$HOME/gitsecret" make install + make install - name: Decrypt secrets env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} From dfa98744db9a0d1e9ac4467e8960bfdb10b13584 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:47:52 -0800 Subject: [PATCH 14/64] Add details. Debug $PATH. --- .github/workflows/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a2dcdfcbabe..45fccdc1e3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -159,9 +159,14 @@ jobs: cd $HOME/oppia-bazel unzip bazel-tools.zip tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools - - name: Install git-secret (https://git-secret.io/installation) + # See https://git-secret.io/installation for details on installing git-secret. Note that the + # apt-get method isn't used since it's much slower to update & upgrade apt before installation + # versus just directly cloning & installing the project. Further, the specific version + # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. + - name: Install git-secret run: | cd $HOME + echo $PATH git clone https://github.com/sobolevn/git-secret.git git-secret cd git-secret && make build make install From 3064c24931458cd8f854b3146140b7ac90ae89a9 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:53:24 -0800 Subject: [PATCH 15/64] Fix pathing for git-secret. --- .github/workflows/main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45fccdc1e3e..742eeceb7c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -163,13 +163,16 @@ jobs: # apt-get method isn't used since it's much slower to update & upgrade apt before installation # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. + # This also uses a different directory to install git-secret to avoid requiring root access + # when running the git secret command. - name: Install git-secret run: | cd $HOME - echo $PATH + mkdir -p $HOME/gitsecret + echo "$HOME/gitsecret" >> $GITHUB_PATH git clone https://github.com/sobolevn/git-secret.git git-secret cd git-secret && make build - make install + PREFIX="$HOME/gitsecret" make install - name: Decrypt secrets env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} From 2fd86631459063bef12334b8661331b054b491e4 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 14:57:34 -0800 Subject: [PATCH 16/64] Dummy commit to re-trigger actions. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 742eeceb7c8..888b524426a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. + # when running the git secret command.. - name: Install git-secret run: | cd $HOME From e099d9d926dcd40a32d9e39db4d91fb29bb9aa03 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 15:00:48 -0800 Subject: [PATCH 17/64] Undo commit to see if this one shows up. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 888b524426a..742eeceb7c8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command.. + # when running the git secret command. - name: Install git-secret run: | cd $HOME From 54e7996cbcbe36db382b3f2560043c4b2c5d501c Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 15:02:58 -0800 Subject: [PATCH 18/64] Fix git-secret pathing try 2. --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 742eeceb7c8..562f7c48830 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -169,10 +169,11 @@ jobs: run: | cd $HOME mkdir -p $HOME/gitsecret - echo "$HOME/gitsecret" >> $GITHUB_PATH git clone https://github.com/sobolevn/git-secret.git git-secret cd git-secret && make build PREFIX="$HOME/gitsecret" make install + echo "$HOME/gitsecret" >> $GITHUB_PATH + echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - name: Decrypt secrets env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} From 17a4cf2ae2e7dac9fea37d1fae84264edd304513 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 15:04:53 -0800 Subject: [PATCH 19/64] New commit to re-trigger action. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 562f7c48830..ee01254dfac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. + # when running the git secret command.. - name: Install git-secret run: | cd $HOME From 5013d2e8238edbb471d0ff9949c8dc6e2c5476f3 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 15:06:06 -0800 Subject: [PATCH 20/64] Path debugging. --- .github/workflows/main.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee01254dfac..b3cb3b13138 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command.. + # when running the git secret command. - name: Install git-secret run: | cd $HOME @@ -174,6 +174,8 @@ jobs: PREFIX="$HOME/gitsecret" make install echo "$HOME/gitsecret" >> $GITHUB_PATH echo "$HOME/gitsecret/bin" >> $GITHUB_PATH + echo "Path:" + echo $PATH - name: Decrypt secrets env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} @@ -183,6 +185,8 @@ jobs: echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE + echo "Path:" + echo $PATH git secret reveal - name: Unzip Bazel binary and build all Oppia targets env: From ed344b045b94ab96472a56308222115c07071bc8 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 15:07:54 -0800 Subject: [PATCH 21/64] Workaround to get GitHub to show changes. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3cb3b13138..8a876ecdbda 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,7 +164,7 @@ jobs: # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command. + # when running the git secret command.. - name: Install git-secret run: | cd $HOME From dce41332c1475188d74487ed2c60c2f4588c2f2f Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 15:12:43 -0800 Subject: [PATCH 22/64] Update runner to use Bash. Reference: https://github.community/t/github-path-does-not-add-to-the-path/143992. --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8a876ecdbda..c6af17a3c9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -164,8 +164,9 @@ jobs: # versus just directly cloning & installing the project. Further, the specific version # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access - # when running the git secret command.. + # when running the git secret command. - name: Install git-secret + shell: bash run: | cd $HOME mkdir -p $HOME/gitsecret From 8794e18ac0d01e255952e73f44cdb0934552a618 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 16:19:23 -0800 Subject: [PATCH 23/64] Restore binary-only build, other builds, and introduce new workflow for building all Bazel targets. --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c6af17a3c9b..d3818d19bea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,6 @@ on: jobs: linters: name: Lint Tests - if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -48,7 +47,6 @@ jobs: robolectric_tests: name: Robolectric Tests (Non-App Modules) - if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -106,7 +104,6 @@ jobs: app_tests: name: Robolectric Tests - App Module (Non-Flaky) - if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -147,6 +144,42 @@ jobs: uses: jwlawson/actions-setup-bazel@v1 with: bazel-version: '3.4.1' + - name: Clone Oppia Bazel + run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel + - name: Set up JDK 9 + uses: actions/setup-java@v1 + with: + java-version: 9 + - name: Extract Android tools + run: | + mkdir -p $GITHUB_WORKSPACE/tmp/android_tools + cd $HOME/oppia-bazel + unzip bazel-tools.zip + tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools + - name: Unzip Bazel binary and build all Oppia targets + run: | + cd $HOME/oppia-bazel + unzip bazel-build.zip + cd $GITHUB_WORKSPACE + chmod a+x $HOME/oppia-bazel/bazel + $HOME/oppia-bazel/bazel build --keep_going --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx -- //:oppia + cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ + - uses: actions/upload-artifact@v2 + with: + name: oppia-bazel-apk + path: /home/runner/work/oppia-android/oppia-android/oppia.apk + - uses: actions/checkout@v2 + + bazel_build_all_with_caching: + name: Build All Bazel Targets (with caching) + # Caching only works for workflows started on non-forks since it requires access to secrets. + if: github.repository == 'oppia/oppia-android' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] + steps: + - uses: actions/checkout@v2 - name: Clone Oppia Bazel run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel - name: Set up JDK 9 @@ -204,4 +237,3 @@ jobs: name: oppia-bazel-apk path: /home/runner/work/oppia-android/oppia-android/oppia.apk - uses: actions/checkout@v2 - From f7b10f254736319edcaf122a9ea4f5a33cb1bef5 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 18 Nov 2020 16:22:14 -0800 Subject: [PATCH 24/64] Remove debug lines. --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d3818d19bea..8f382a738b2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -208,8 +208,6 @@ jobs: PREFIX="$HOME/gitsecret" make install echo "$HOME/gitsecret" >> $GITHUB_PATH echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - echo "Path:" - echo $PATH - name: Decrypt secrets env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} @@ -219,8 +217,6 @@ jobs: echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE - echo "Path:" - echo $PATH git secret reveal - name: Unzip Bazel binary and build all Oppia targets env: From 9cbd94c3eb9c5966cf2175140ade805ab0cf9a67 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 15:37:03 -0800 Subject: [PATCH 25/64] Rename & remove keep_going. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8f382a738b2..e82b6f76b72 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -156,13 +156,13 @@ jobs: cd $HOME/oppia-bazel unzip bazel-tools.zip tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools - - name: Unzip Bazel binary and build all Oppia targets + - name: Unzip Bazel binary and build Oppia binary run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build --keep_going --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx -- //:oppia + $HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx -- //:oppia cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - uses: actions/upload-artifact@v2 with: From 2aa09446b21f464b2b4bf9c63ad0989781f7d743 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 18:07:52 -0800 Subject: [PATCH 26/64] Compute matrix containing all test targets. This will allow us to distribute parallelization responsibilities partly to GitHub actions to hopefully have slightly better throughput. See https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/ for reference on how this mechanism works. --- .github/workflows/main.yml | 76 ++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e82b6f76b72..e0897e4dfdf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -170,14 +170,13 @@ jobs: path: /home/runner/work/oppia-android/oppia-android/oppia.apk - uses: actions/checkout@v2 - bazel_build_all_with_caching: - name: Build All Bazel Targets (with caching) + bazel_build_binary_with_caching: + name: Build Bazel Binary (with caching) # Caching only works for workflows started on non-forks since it requires access to secrets. if: github.repository == 'oppia/oppia-android' - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04] + runs-on: ubuntu-18.04 + outputs: + matrix: ${{ steps.compute-test-matrix.outputs.matrix }} steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -226,10 +225,73 @@ jobs: unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build --keep_going --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //... + $HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ + - id: compute-test-matrix + # TODO(#1861): update the query below to compute only affected targets (more useful after + # the codebase is more split up). + # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly + # comma-separated list of test targets for the matrix. + run: | + TEST_TARGET_LIST=$($HOME/oppia-bazel/bazel query "tests(//...)" 2>/dev/null | sed 's/^\|$/"/g' | paste -sd, -) + echo "Test target list: $TEST_TARGET_LIST" + echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" - uses: actions/upload-artifact@v2 with: name: oppia-bazel-apk path: /home/runner/work/oppia-android/oppia-android/oppia.apk - uses: actions/checkout@v2 + + bazel_run_test_with_caching: + name: Run Bazel Test (with caching) + # Caching only works for workflows started on non-forks since it requires access to secrets. + if: github.repository == 'oppia/oppia-android' + needs: bazel_build_binary_with_caching + runs-on: ubuntu-18.04 + strategy: + matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix}} + steps: + - uses: actions/checkout@v2 + - name: Clone Oppia Bazel + run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel + - name: Set up JDK 9 + uses: actions/setup-java@v1 + with: + java-version: 9 + - name: Extract Android tools + run: | + mkdir -p $GITHUB_WORKSPACE/tmp/android_tools + cd $HOME/oppia-bazel + unzip bazel-tools.zip + tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools + # See explanation in bazel_build_binary_with_caching for how this is installed. + - name: Install git-secret + shell: bash + run: | + cd $HOME + mkdir -p $HOME/gitsecret + git clone https://github.com/sobolevn/git-secret.git git-secret + cd git-secret && make build + PREFIX="$HOME/gitsecret" make install + echo "$HOME/gitsecret" >> $GITHUB_PATH + echo "$HOME/gitsecret/bin" >> $GITHUB_PATH + - name: Decrypt secrets + env: + GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} + run: | + cd $HOME + # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! + echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg + gpg --import ./git_secret_private_key.gpg + cd $GITHUB_WORKSPACE + git secret reveal + - name: Unzip Bazel binary and build all Oppia targets + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + run: | + cd $HOME/oppia-bazel + unzip bazel-build.zip + cd $GITHUB_WORKSPACE + chmod a+x $HOME/oppia-bazel/bazel + $HOME/oppia-bazel/bazel test --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:${{ matrix.test-target }} + - uses: actions/checkout@v2 From 226c4a1788dd3b8d4ab00df96a3965a75583fb55 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 18:12:17 -0800 Subject: [PATCH 27/64] Simplify, fix some issues, and debug instead of run. --- .github/workflows/main.yml | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0897e4dfdf..22524fd8390 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,10 +17,8 @@ on: jobs: linters: name: Lint Tests - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04] + if: false + runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 @@ -47,10 +45,8 @@ jobs: robolectric_tests: name: Robolectric Tests (Non-App Modules) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04] + if: false + runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 @@ -104,11 +100,9 @@ jobs: app_tests: name: Robolectric Tests - App Module (Non-Flaky) - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04] - steps: + if: false + runs-on: ubuntu-18.04 + steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 @@ -220,13 +214,13 @@ jobs: - name: Unzip Bazel binary and build all Oppia targets env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + #$HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia + #cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia - cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - id: compute-test-matrix # TODO(#1861): update the query below to compute only affected targets (more useful after # the codebase is more split up). @@ -249,7 +243,7 @@ jobs: needs: bazel_build_binary_with_caching runs-on: ubuntu-18.04 strategy: - matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix}} + matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix)}} steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -288,10 +282,11 @@ jobs: - name: Unzip Bazel binary and build all Oppia targets env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + #$HOME/oppia-bazel/bazel test --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel test --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:${{ matrix.test-target }} + echo ${{ matrix.test-target }} - uses: actions/checkout@v2 From 7ae7e5ffea5ea07bd536b85c9dae9c45eca92485 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 18:24:52 -0800 Subject: [PATCH 28/64] Turn on actual testing. --- .github/workflows/main.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22524fd8390..5963de02a2e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -128,6 +128,7 @@ jobs: bazel_build_app: name: Build Binary with Bazel + if: false runs-on: ${{ matrix.os }} strategy: matrix: @@ -214,14 +215,15 @@ jobs: - name: Unzip Bazel binary and build all Oppia targets env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - #$HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia - #cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - - id: compute-test-matrix + $HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia + cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ + - name: Compute test matrix to parallelize in GitHub Actions + id: compute-test-matrix # TODO(#1861): update the query below to compute only affected targets (more useful after # the codebase is more split up). # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly @@ -282,11 +284,10 @@ jobs: - name: Unzip Bazel binary and build all Oppia targets env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - #$HOME/oppia-bazel/bazel test --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - echo ${{ matrix.test-target }} + $HOME/oppia-bazel/bazel test --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} - uses: actions/checkout@v2 From f26276e23775676544fc05fd057ee4c22bde005c Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 19:08:51 -0800 Subject: [PATCH 29/64] Lower parallelization since GitHub started cancelling tasks. --- .github/workflows/main.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5963de02a2e..2330b9cfa58 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -212,7 +212,7 @@ jobs: gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - - name: Unzip Bazel binary and build all Oppia targets + - name: Unzip Bazel binary and build Oppia binary env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} run: | @@ -245,6 +245,7 @@ jobs: needs: bazel_build_binary_with_caching runs-on: ubuntu-18.04 strategy: + max-parallel: 25 matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix)}} steps: - uses: actions/checkout@v2 @@ -281,7 +282,7 @@ jobs: gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - - name: Unzip Bazel binary and build all Oppia targets + - name: Unzip Bazel binary and run Oppia test env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} run: | From 1850784a18e595220cf6c23c4e2b0229a8ae24a5 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 19:39:42 -0800 Subject: [PATCH 30/64] Try 15 parallel jobs instead. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2330b9cfa58..0893a5304a3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -245,7 +245,7 @@ jobs: needs: bazel_build_binary_with_caching runs-on: ubuntu-18.04 strategy: - max-parallel: 25 + max-parallel: 15 matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix)}} steps: - uses: actions/checkout@v2 From 49b3584f531c2e0d23667878a27e382cc8bf831e Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 19 Nov 2020 21:14:11 -0800 Subject: [PATCH 31/64] Turn off fail-fast instead of limiting parallelization. Fail fast seems to be the reason why the tests aren't completing, not quota (since if too many jobs are started, the extras should just be queued until resources open up). --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0893a5304a3..6cfce036531 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -245,7 +245,7 @@ jobs: needs: bazel_build_binary_with_caching runs-on: ubuntu-18.04 strategy: - max-parallel: 15 + fail-fast: false matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix)}} steps: - uses: actions/checkout@v2 From c1546cb1749ba49d958d82718e2c612dbb18d879 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 10:50:34 -0800 Subject: [PATCH 32/64] Simplify workflow & allow it to be required. Also, introduce bazelrc file to simplify the CI CLIs interacting with Bazel. --- .bazelrc | 6 +++ .github/workflows/main.yml | 97 +++++++++++++++----------------------- 2 files changed, 43 insertions(+), 60 deletions(-) create mode 100644 .bazelrc diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 00000000000..4d31c933410 --- /dev/null +++ b/.bazelrc @@ -0,0 +1,6 @@ +# Configurations for arguments that should automatically be added to Bazel commands. +build --android_databinding_use_v3_4_args \ + --experimental_android_databinding_v2 \ + --java_header_compilation=false \ + --noincremental_dexing \ + --define=android_standalone_dexing_tool=d8_compat_dx diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6cfce036531..0c064744396 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -127,48 +127,7 @@ jobs: path: app/build/reports bazel_build_app: - name: Build Binary with Bazel - if: false - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-18.04] - steps: - - uses: actions/checkout@v2 - - name: Set up Bazel - uses: jwlawson/actions-setup-bazel@v1 - with: - bazel-version: '3.4.1' - - name: Clone Oppia Bazel - run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel - - name: Set up JDK 9 - uses: actions/setup-java@v1 - with: - java-version: 9 - - name: Extract Android tools - run: | - mkdir -p $GITHUB_WORKSPACE/tmp/android_tools - cd $HOME/oppia-bazel - unzip bazel-tools.zip - tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools - - name: Unzip Bazel binary and build Oppia binary - run: | - cd $HOME/oppia-bazel - unzip bazel-build.zip - cd $GITHUB_WORKSPACE - chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx -- //:oppia - cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - - uses: actions/upload-artifact@v2 - with: - name: oppia-bazel-apk - path: /home/runner/work/oppia-android/oppia-android/oppia.apk - - uses: actions/checkout@v2 - - bazel_build_binary_with_caching: - name: Build Bazel Binary (with caching) - # Caching only works for workflows started on non-forks since it requires access to secrets. - if: github.repository == 'oppia/oppia-android' + name: Build Bazel Binary runs-on: ubuntu-18.04 outputs: matrix: ${{ steps.compute-test-matrix.outputs.matrix }} @@ -192,7 +151,8 @@ jobs: # shouldn't matter since git-secret relies on a future-proof storage mechanism for secrets. # This also uses a different directory to install git-secret to avoid requiring root access # when running the git secret command. - - name: Install git-secret + - name: Install git-secret (non-fork only) + if: github.repository == 'oppia/oppia-android' shell: bash run: | cd $HOME @@ -202,7 +162,8 @@ jobs: PREFIX="$HOME/gitsecret" make install echo "$HOME/gitsecret" >> $GITHUB_PATH echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - name: Decrypt secrets + - name: Decrypt secrets (non-fork only) + if: github.repository == 'oppia/oppia-android' env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} run: | @@ -212,16 +173,25 @@ jobs: gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - - name: Unzip Bazel binary and build Oppia binary - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + - name: Unzip Bazel binary run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel build --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia - cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ + # Note that caching only works on non-forks. + - name: Build Oppia binary (with caching, non-fork only) + if: github.repository == 'oppia/oppia-android' + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + run: | + $HOME/oppia-bazel/bazel build --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- //:oppia + - name: Build Oppia binary (without caching, fork only) + if: github.repository != 'oppia/oppia-android' + run: | + $HOME/oppia-bazel/bazel build --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- //:oppia + - name: Copy Oppia APK for uploading + run: cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ - name: Compute test matrix to parallelize in GitHub Actions id: compute-test-matrix # TODO(#1861): update the query below to compute only affected targets (more useful after @@ -240,13 +210,11 @@ jobs: bazel_run_test_with_caching: name: Run Bazel Test (with caching) - # Caching only works for workflows started on non-forks since it requires access to secrets. - if: github.repository == 'oppia/oppia-android' - needs: bazel_build_binary_with_caching + needs: bazel_build_app runs-on: ubuntu-18.04 strategy: fail-fast: false - matrix: ${{fromJson(needs.bazel_build_binary_with_caching.outputs.matrix)}} + matrix: ${{fromJson(needs.bazel_build_app.outputs.matrix)}} steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -261,8 +229,9 @@ jobs: cd $HOME/oppia-bazel unzip bazel-tools.zip tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools - # See explanation in bazel_build_binary_with_caching for how this is installed. - - name: Install git-secret + # See explanation in bazel_build_app for how this is installed. + - name: Install git-secret (non-fork only) + if: github.repository == 'oppia/oppia-android' shell: bash run: | cd $HOME @@ -272,7 +241,8 @@ jobs: PREFIX="$HOME/gitsecret" make install echo "$HOME/gitsecret" >> $GITHUB_PATH echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - name: Decrypt secrets + - name: Decrypt secrets (non-fork only) + if: github.repository == 'oppia/oppia-android' env: GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} run: | @@ -282,13 +252,20 @@ jobs: gpg --import ./git_secret_private_key.gpg cd $GITHUB_WORKSPACE git secret reveal - - name: Unzip Bazel binary and run Oppia test - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + - name: Unzip Bazel binary run: | cd $HOME/oppia-bazel unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - $HOME/oppia-bazel/bazel test --android_databinding_use_v3_4_args --experimental_android_databinding_v2 --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --java_header_compilation=false --noincremental_dexing --define=android_standalone_dexing_tool=d8_compat_dx --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} + - name: Run Oppia Test (with caching, non-fork only) + if: github.repository == 'oppia/oppia-android' + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} + - name: Run Oppia Test (without caching, fork only) + if: github.repository != 'oppia/oppia-android' + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + run: $HOME/oppia-bazel/bazel test --test_output=all --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} - uses: actions/checkout@v2 From dcda5834759c0564887b8ee514f0b089ce527d1d Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 10:51:12 -0800 Subject: [PATCH 33/64] Add test change to investigate computing affected targets. --- .../oppia/android/app/player/state/StateFragmentLocalTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 8823299d0bf..9a4eadd5e09 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -136,6 +136,8 @@ class StateFragmentLocalTest { private val internalProfileId: Int = 1 private val solutionIndex: Int = 4 + // extra line to indicate the test changed + @Before fun setUp() { setUpTestApplicationComponent() From 4aff1a88b02a2dba57b51ee436f52efe8ffdb47b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 10:55:11 -0800 Subject: [PATCH 34/64] Another test change to compute affected targets. --- .../app/player/state/StatePlayerRecyclerViewAssembler.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt b/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt index 6204e1ed35d..2f932425ead 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt @@ -134,6 +134,8 @@ class StatePlayerRecyclerViewAssembler private constructor( delayShowAdditionalHintsMs: Long, delayShowAdditionalHintsFromWrongAnswerMs: Long ) : HtmlParser.CustomOppiaTagActionListener { + // Test change to see what tests this affects. + /** * A list of view models corresponding to past view models that are hidden by default. These are * intentionally not retained upon configuration changes since the user can just re-expand the From d5904c1c60aa385106fe9d6d7e95a7d1b2fbacba Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 11:50:57 -0800 Subject: [PATCH 35/64] Update workflow to use future script compute_affected_tests.sh. Also, ignore Bazel directories in Git (to ease local development). --- .github/workflows/main.yml | 4 ++-- .gitignore | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0c064744396..74b905ac7bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -199,8 +199,8 @@ jobs: # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly # comma-separated list of test targets for the matrix. run: | - TEST_TARGET_LIST=$($HOME/oppia-bazel/bazel query "tests(//...)" 2>/dev/null | sed 's/^\|$/"/g' | paste -sd, -) - echo "Test target list: $TEST_TARGET_LIST" + TEST_TARGET_LIST=$(bash ./scripts/compute_affected_tests.sh $HOME/oppia-bazel/bazel | sed 's/^\|$/"/g' | paste -sd, -) + echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" - uses: actions/upload-artifact@v2 with: diff --git a/.gitignore b/.gitignore index 67dfc7158ef..fe10fc61e64 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,4 @@ gradlew.bat .gitsecret/keys/random_seed !*.secret config/oppia-dev-workflow-remote-cache-credentials.json +bazel-* From 479d683c1ab586dac88d6d81554143b3adef5ed7 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 11:59:19 -0800 Subject: [PATCH 36/64] Add script to compute affected targets. This script is primarily meant to be used for CI. --- scripts/compute_affected_tests.sh | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 scripts/compute_affected_tests.sh diff --git a/scripts/compute_affected_tests.sh b/scripts/compute_affected_tests.sh new file mode 100755 index 00000000000..8271eabbf8b --- /dev/null +++ b/scripts/compute_affected_tests.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Compute the list of tests that are affected by changes on this branch (including in the working +# directory). This script is useful to verify that only the tests that could break due to a change +# are actually verified as passing. Note that this script does not actually run any of the tests. +# +# Usage: +# bash scripts/compute_affected_tests.sh +# +# This script is based on https://github.com/bazelbuild/bazel/blob/d96e1cd/scripts/ci/ci.sh and the +# documentation at https://docs.bazel.build/versions/master/query.html. Note that this script will +# automatically list all tests if it's run on the develop branch (the idea being that test +# considerations on the develop branch should always consider all targets). + +BAZEL_BINARY=$1 + +# Reference: https://stackoverflow.com/a/6245587. +current_branch=$(git branch --show-current) + +if [ "$current_branch" != "develop" ]; then + # https://stackoverflow.com/a/9294015 for constructing the arrays. + commit_range=HEAD..$(git merge-base origin/develop HEAD) + changed_committed_files=($(git diff --name-only $commit_range)) + changed_staged_files=($(git diff --name-only --cached)) + changed_unstaged_files=($(git diff --name-only)) + # See https://stackoverflow.com/a/35484355 for how this works. + changed_untracked_files=($(git ls-files --others --exclude-standard)) + + changed_files_with_potential_duplicates=( + "${changed_committed_files[@]}" + "${changed_staged_files[@]}" + "${changed_unstaged_files[@]}" + "${changed_untracked_files[@]}" + ) + # De-duplicated files: https://unix.stackexchange.com/q/377812. + changed_files=($(printf "%s\n" "${changed_files_with_potential_duplicates[@]}" | sort -u)) + + # Filter all of the source files among those that are actually included in Bazel builds. + changed_bazel_files=() + for changed_file in ${changed_files[@]}; do + changed_bazel_files+=($($BAZEL_BINARY query --noshow_progress $changed_file 2> /dev/null)) + done + + # Compute the list of affected tests. + $BAZEL_BINARY query --noshow_progress "kind(test, rdeps(//..., set(${changed_bazel_files[@]})))" 2>/dev/null +else + # Print all test targets. + $BAZEL_BINARY query --noshow_progress "kind(test, //...)" 2>/dev/null +fi From c2c9fcd5c8dbde3627b7dafce1900c68b70ed7e3 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 12:03:49 -0800 Subject: [PATCH 37/64] Execute tests in parallel to build. This creates a new job to compute affected targets alongside the build. This may result in the initial build being a bit slower, but subsequent commits should be fast if remote caching is enabled. This will also result in better performance for forks that can't use remote caching. --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 74b905ac7bd..3904d89e27a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,8 +129,6 @@ jobs: bazel_build_app: name: Build Bazel Binary runs-on: ubuntu-18.04 - outputs: - matrix: ${{ steps.compute-test-matrix.outputs.matrix }} steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -192,6 +190,26 @@ jobs: $HOME/oppia-bazel/bazel build --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- //:oppia - name: Copy Oppia APK for uploading run: cp $GITHUB_WORKSPACE/bazel-bin/oppia.apk /home/runner/work/oppia-android/oppia-android/ + - uses: actions/upload-artifact@v2 + with: + name: oppia-bazel-apk + path: /home/runner/work/oppia-android/oppia-android/oppia.apk + + bazel_compute_affected_targets: + name: Compute affected tests + runs-on: ubuntu-18.04 + outputs: + matrix: ${{ steps.compute-test-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + - name: Clone Oppia Bazel + run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel + - name: Unzip Bazel binary + run: | + cd $HOME/oppia-bazel + unzip bazel-build.zip + cd $GITHUB_WORKSPACE + chmod a+x $HOME/oppia-bazel/bazel - name: Compute test matrix to parallelize in GitHub Actions id: compute-test-matrix # TODO(#1861): update the query below to compute only affected targets (more useful after @@ -202,19 +220,14 @@ jobs: TEST_TARGET_LIST=$(bash ./scripts/compute_affected_tests.sh $HOME/oppia-bazel/bazel | sed 's/^\|$/"/g' | paste -sd, -) echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" - - uses: actions/upload-artifact@v2 - with: - name: oppia-bazel-apk - path: /home/runner/work/oppia-android/oppia-android/oppia.apk - - uses: actions/checkout@v2 - bazel_run_test_with_caching: - name: Run Bazel Test (with caching) - needs: bazel_build_app + bazel_run_test: + name: Run Bazel Test + needs: bazel_compute_affected_targets runs-on: ubuntu-18.04 strategy: fail-fast: false - matrix: ${{fromJson(needs.bazel_build_app.outputs.matrix)}} + matrix: ${{fromJson(needs.bazel_compute_affected_targets.outputs.matrix)}} steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -268,4 +281,3 @@ jobs: env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} run: $HOME/oppia-bazel/bazel test --test_output=all --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} - - uses: actions/checkout@v2 From 372f2f45563d69485d2b660099f341e7ac914e46 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 12:14:48 -0800 Subject: [PATCH 38/64] Script clean-ups. Also, re-trigger actions. --- scripts/compute_affected_tests.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/compute_affected_tests.sh b/scripts/compute_affected_tests.sh index 8271eabbf8b..782a5795d77 100755 --- a/scripts/compute_affected_tests.sh +++ b/scripts/compute_affected_tests.sh @@ -18,7 +18,8 @@ BAZEL_BINARY=$1 current_branch=$(git branch --show-current) if [ "$current_branch" != "develop" ]; then - # https://stackoverflow.com/a/9294015 for constructing the arrays. + # Compute all files that have been changed on this branch. https://stackoverflow.com/a/9294015 for + # constructing the arrays. commit_range=HEAD..$(git merge-base origin/develop HEAD) changed_committed_files=($(git diff --name-only $commit_range)) changed_staged_files=($(git diff --name-only --cached)) @@ -32,7 +33,8 @@ if [ "$current_branch" != "develop" ]; then "${changed_unstaged_files[@]}" "${changed_untracked_files[@]}" ) - # De-duplicated files: https://unix.stackexchange.com/q/377812. + + # De-duplicate files: https://unix.stackexchange.com/q/377812. changed_files=($(printf "%s\n" "${changed_files_with_potential_duplicates[@]}" | sort -u)) # Filter all of the source files among those that are actually included in Bazel builds. From 5c888de2b83a0560465ca80089a840d2785c059a Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 14:06:15 -0800 Subject: [PATCH 39/64] Try to ensure develop branch is available for change analysis. --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3904d89e27a..559df3161af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -129,6 +129,7 @@ jobs: bazel_build_app: name: Build Bazel Binary runs-on: ubuntu-18.04 + if: false steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -202,6 +203,8 @@ jobs: matrix: ${{ steps.compute-test-matrix.outputs.matrix }} steps: - uses: actions/checkout@v2 + with: + fetch-depth: 0 - name: Clone Oppia Bazel run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel - name: Unzip Bazel binary From 0bd553244efabd56fadf087f808c829b093e8832 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 14:43:18 -0800 Subject: [PATCH 40/64] Add automatic workflow cancellation. Also, add support to explicitly run all tests if '[RunAllTests]' is in the PR title. --- .github/workflows/main.yml | 12 +++++++++--- .github/workflows/workflow_canceller.yml | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/workflow_canceller.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 559df3161af..7f25c902bd3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -213,16 +213,22 @@ jobs: unzip bazel-build.zip cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - - name: Compute test matrix to parallelize in GitHub Actions + - name: Compute test matrix based on affected targets id: compute-test-matrix - # TODO(#1861): update the query below to compute only affected targets (more useful after - # the codebase is more split up). + if: "!contains(github.event.pull_request.title, '[RunAllTests]')" # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly # comma-separated list of test targets for the matrix. run: | TEST_TARGET_LIST=$(bash ./scripts/compute_affected_tests.sh $HOME/oppia-bazel/bazel | sed 's/^\|$/"/g' | paste -sd, -) echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" + - name: Compute test matrix based on all tests + id: compute-test-matrix + if: "contains(github.event.pull_request.title, '[RunAllTests]')" + run: | + TEST_TARGET_LIST=$($HOME/oppia-bazel/bazel query "kind(test, //...)" | sed 's/^\|$/"/g' | paste -sd, -) + echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" + echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" bazel_run_test: name: Run Bazel Test diff --git a/.github/workflows/workflow_canceller.yml b/.github/workflows/workflow_canceller.yml new file mode 100644 index 00000000000..b3402485e7a --- /dev/null +++ b/.github/workflows/workflow_canceller.yml @@ -0,0 +1,19 @@ +name: Automatic Workflow Canceller + +on: + workflow_dispatch: + pull_request: + push: + branches: + # Push events on develop branch + - develop + +jobs: + cancel: + name: Cancel Previous Runs + runs-on: ubuntu-18.04 + steps: + - uses: styfle/cancel-workflow-action@0.6.0 + with: + workflow_id: main.yml + access_token: ${{ github.token }} From fe0fec6c2977506c910c983a91f7c235e1e894c5 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 14:48:46 -0800 Subject: [PATCH 41/64] Attempt to make conditional matrix computation work. --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f25c902bd3..40b7f38d85e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -200,7 +200,7 @@ jobs: name: Compute affected tests runs-on: ubuntu-18.04 outputs: - matrix: ${{ steps.compute-test-matrix.outputs.matrix }} + matrix: ${{ join(steps.compute-test-matrix-from-affected.outputs.matrix, steps.compute-test-matrix-from-all.outputs.matrix) }} steps: - uses: actions/checkout@v2 with: @@ -214,7 +214,7 @@ jobs: cd $GITHUB_WORKSPACE chmod a+x $HOME/oppia-bazel/bazel - name: Compute test matrix based on affected targets - id: compute-test-matrix + id: compute-test-matrix-from-affected if: "!contains(github.event.pull_request.title, '[RunAllTests]')" # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly # comma-separated list of test targets for the matrix. @@ -223,7 +223,7 @@ jobs: echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" - name: Compute test matrix based on all tests - id: compute-test-matrix + id: compute-test-matrix-from-all if: "contains(github.event.pull_request.title, '[RunAllTests]')" run: | TEST_TARGET_LIST=$($HOME/oppia-bazel/bazel query "kind(test, //...)" | sed 's/^\|$/"/g' | paste -sd, -) From 1155a9f13598cf434a6a371ae8388fe0ece0baab Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 15:03:39 -0800 Subject: [PATCH 42/64] Remove join since it was used incorrectly. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 40b7f38d85e..8b12c7475c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -200,7 +200,7 @@ jobs: name: Compute affected tests runs-on: ubuntu-18.04 outputs: - matrix: ${{ join(steps.compute-test-matrix-from-affected.outputs.matrix, steps.compute-test-matrix-from-all.outputs.matrix) }} + matrix: ${{ steps.compute-test-matrix-from-affected.outputs.matrix || steps.compute-test-matrix-from-all.outputs.matrix }} steps: - uses: actions/checkout@v2 with: From 1b25e34341a48b61de4ea07971258f8f102890cd Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 16:42:12 -0800 Subject: [PATCH 43/64] Add support for testing when Bazel, BUILD, and WORKSPACE files change. One consequence is the current Bazel file structure is very tight, so any changes will likely run the whole suite. This will get better over time. Also, show test logs for all test runs. --- .bazelrc | 3 +++ .github/workflows/main.yml | 2 +- scripts/compute_affected_tests.sh | 32 ++++++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index 4d31c933410..71793d2ba7c 100644 --- a/.bazelrc +++ b/.bazelrc @@ -4,3 +4,6 @@ build --android_databinding_use_v3_4_args \ --java_header_compilation=false \ --noincremental_dexing \ --define=android_standalone_dexing_tool=d8_compat_dx + +# Show all test output by default (for better debugging). +test --test_output=all diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b12c7475c5..277db738671 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -289,4 +289,4 @@ jobs: if: github.repository != 'oppia/oppia-android' env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: $HOME/oppia-bazel/bazel test --test_output=all --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} + run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} diff --git a/scripts/compute_affected_tests.sh b/scripts/compute_affected_tests.sh index 782a5795d77..0b4990a47e0 100755 --- a/scripts/compute_affected_tests.sh +++ b/scripts/compute_affected_tests.sh @@ -17,7 +17,7 @@ BAZEL_BINARY=$1 # Reference: https://stackoverflow.com/a/6245587. current_branch=$(git branch --show-current) -if [ "$current_branch" != "develop" ]; then +if [[ "$current_branch" != "develop" ]]; then # Compute all files that have been changed on this branch. https://stackoverflow.com/a/9294015 for # constructing the arrays. commit_range=HEAD..$(git merge-base origin/develop HEAD) @@ -43,8 +43,34 @@ if [ "$current_branch" != "develop" ]; then changed_bazel_files+=($($BAZEL_BINARY query --noshow_progress $changed_file 2> /dev/null)) done - # Compute the list of affected tests. - $BAZEL_BINARY query --noshow_progress "kind(test, rdeps(//..., set(${changed_bazel_files[@]})))" 2>/dev/null + # Compute the list of affected tests based on source files. + source_affected_targets=$($BAZEL_BINARY query --noshow_progress --universe_scope=//... --order_output=no "kind(test, allrdeps(set(${changed_bazel_files[@]})))" 2>/dev/null) + + # Compute the list of files to consider for BUILD-level changes (this uses the base file list as a + # reference since Bazel's query won't find matching targets for utility bzl files that can still + # affect the build). https://stackoverflow.com/a/44107086 for reference on changing case matching. + shopt -s nocasematch + changed_bazel_support_files=() + for changed_file in ${changed_files[@]}; do + if [[ "$changed_file" =~ ^.+?\.bazel$ ]] || [[ "$changed_file" =~ ^.+?\.bzl$ ]] || [[ "$changed_file" == "WORKSPACE" ]]; then + changed_bazel_support_files+=($changed_file) + fi + done + shopt -u nocasematch + + # Compute the list of affected tests based on BUILD/Bazel/WORKSPACE files. These are generally + # framed as: if a BUILD file changes, run all tests transitively connected to it. + # Reference for joining an array to string: https://stackoverflow.com/a/53839433. + printf -v changed_bazel_support_files_list '%s,' "${changed_bazel_support_files[@]}" + build_affected_targets=$($BAZEL_BINARY query --noshow_progress --universe_scope=//... --order_output=no "filter('^[^@]', kind(test, allrdeps(siblings(rbuildfiles(${changed_bazel_support_files_list%,})))))" 2>/dev/null) + + all_affected_targets_with_potential_duplicated=( + "${source_affected_targets[@]}" + "${build_affected_targets[@]}" + ) + + # Print all of the affected targets without duplicates. + printf "%s\n" "${all_affected_targets_with_potential_duplicated[@]}" | sort -u else # Print all test targets. $BAZEL_BINARY query --noshow_progress "kind(test, //...)" 2>/dev/null From 86c5c93bb7eac6e05fd41bb0ebb2801d66fa3442 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 16:49:17 -0800 Subject: [PATCH 44/64] Fix broken tests by adding missing dep library. --- domain/BUILD.bazel | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index 2ab358b4514..9ee45784aca 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -23,9 +23,22 @@ kt_android_library( ], ) +# TODO(#2143): Move InteractionObjectTestBuilder to a testing package outside the test folder. +kt_android_library( + name = "interaction_object_test_builder", + testonly = True, + srcs = [ + "src/test/java/org/oppia/android/domain/classify/InteractionObjectTestBuilder.kt", + ], + deps = [ + "//model", + ], +) + TEST_DEPS = [ ":dagger", ":domain", + ":interaction_object_test_builder", "//data:persistent_cache_store", "//model", "//testing", From 7ed040ed8700ec6116985db0d2354973f74d0446 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 18:44:07 -0800 Subject: [PATCH 45/64] Finalize PR. 1. Expand codeowners to include all workflow files. 2. Remove test comments in Kotlin files. 3. Re-enable all workflows. 4. Attempt to fix tests broken on actions but not locally by adding more thread synchronization points. --- .github/CODEOWNERS | 2 +- .github/workflows/main.yml | 4 --- .../state/StatePlayerRecyclerViewAssembler.kt | 2 -- .../player/state/StateFragmentLocalTest.kt | 32 ++++++++++++++++--- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dd191a30d42..75bc528e7cd 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,7 +12,7 @@ # the above date passes. # GitHub Actions & CI workflows. -.github/main.yaml @BenHenning +.github/*.yaml @BenHenning # Blanket codeowners # This is for the case when new files are created in any directories that aren't diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 277db738671..2e64e2b5e7d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,6 @@ on: jobs: linters: name: Lint Tests - if: false runs-on: ubuntu-18.04 steps: @@ -45,7 +44,6 @@ jobs: robolectric_tests: name: Robolectric Tests (Non-App Modules) - if: false runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 @@ -100,7 +98,6 @@ jobs: app_tests: name: Robolectric Tests - App Module (Non-Flaky) - if: false runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 @@ -129,7 +126,6 @@ jobs: bazel_build_app: name: Build Bazel Binary runs-on: ubuntu-18.04 - if: false steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel diff --git a/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt b/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt index 2f932425ead..6204e1ed35d 100644 --- a/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt +++ b/app/src/main/java/org/oppia/android/app/player/state/StatePlayerRecyclerViewAssembler.kt @@ -134,8 +134,6 @@ class StatePlayerRecyclerViewAssembler private constructor( delayShowAdditionalHintsMs: Long, delayShowAdditionalHintsFromWrongAnswerMs: Long ) : HtmlParser.CustomOppiaTagActionListener { - // Test change to see what tests this affects. - /** * A list of view models corresponding to past view models that are hidden by default. These are * intentionally not retained upon configuration changes since the user can just re-expand the diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 9a4eadd5e09..6b4938e7193 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -54,6 +54,7 @@ import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.CONTINUE_NAVIGATION_BUTTON import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.FRACTION_INPUT_INTERACTION import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.NEXT_NAVIGATION_BUTTON +import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.PREVIOUS_NAVIGATION_BUTTON import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.PREVIOUS_RESPONSES_HEADER import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.SELECTION_INTERACTION import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.SUBMIT_ANSWER_BUTTON @@ -136,8 +137,6 @@ class StateFragmentLocalTest { private val internalProfileId: Int = 1 private val solutionIndex: Int = 4 - // extra line to indicate the test changed - @Before fun setUp() { setUpTestApplicationComponent() @@ -288,6 +287,8 @@ class StateFragmentLocalTest { submitTwoWrongAnswers() onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER)) + testCoroutineDispatchers.runCurrent() + onView(withId(R.id.previous_response_header)).check(matches(isDisplayed())) } } @@ -300,6 +301,8 @@ class StateFragmentLocalTest { submitTwoWrongAnswers() onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER)) + testCoroutineDispatchers.runCurrent() + onView(withId(R.id.previous_response_header)).check(matches(isDisplayed())) onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 5))) } @@ -314,7 +317,9 @@ class StateFragmentLocalTest { submitTwoWrongAnswers() onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER)) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.previous_response_header)).perform(click()) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 6))) } } @@ -328,13 +333,18 @@ class StateFragmentLocalTest { submitTwoWrongAnswers() onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER)) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.previous_response_header)).check(matches(isDisplayed())) onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 5))) onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER)) + testCoroutineDispatchers.runCurrent() onView(withSubstring("Previous Responses")).perform(click()) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 6))) onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(PREVIOUS_RESPONSES_HEADER)) + testCoroutineDispatchers.runCurrent() onView(withSubstring("Previous Responses")).perform(click()) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.state_recycler_view)).check(matches(hasChildCount(/* childCount= */ 5))) } } @@ -400,6 +410,9 @@ class StateFragmentLocalTest { playThroughState1() submitTwoWrongAnswers() onView(withId(R.id.hint_bulb)).check(matches(isDisplayed())) + // The previous navigation button is next to a submit answer button in this state. + onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(SUBMIT_ANSWER_BUTTON)) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.previous_state_navigation_button)).perform(click()) testCoroutineDispatchers.runCurrent() onView(withId(R.id.hint_bulb)).check(matches(not(isDisplayed()))) @@ -413,7 +426,7 @@ class StateFragmentLocalTest { playThroughState1() submitTwoWrongAnswers() onView(withId(R.id.dot_hint)).check(matches(isDisplayed())) - moveToPreviousAndBackToCurrentState() + moveToPreviousAndBackToCurrentStateWithSubmitButton() onView(withId(R.id.dot_hint)).check(matches(isDisplayed())) } } @@ -430,7 +443,7 @@ class StateFragmentLocalTest { onView(withText("Reveal Hint")).inRoot(isDialog()).check(matches(isDisplayed())) closeHintsAndSolutionsDialog() - moveToPreviousAndBackToCurrentState() + moveToPreviousAndBackToCurrentStateWithSubmitButton() openHintsAndSolutionsDialog() onView(withText("Hint 1")).inRoot(isDialog()).check(matches(isDisplayed())) @@ -449,6 +462,7 @@ class StateFragmentLocalTest { onView(withId(R.id.previous_state_navigation_button)).perform(click()) testCoroutineDispatchers.runCurrent() onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(NEXT_NAVIGATION_BUTTON)) + testCoroutineDispatchers.runCurrent() onView(withId(R.id.next_state_navigation_button)).perform(click()) testCoroutineDispatchers.runCurrent() @@ -456,6 +470,7 @@ class StateFragmentLocalTest { onView(withId(R.id.hints_and_solution_recycler_view)) .inRoot(isDialog()) .perform(scrollToPosition(0)) + testCoroutineDispatchers.runCurrent() onView( RecyclerViewMatcher.atPositionOnView( R.id.hints_and_solution_recycler_view, 0, R.id.hint_summary_container @@ -711,6 +726,7 @@ class StateFragmentLocalTest { onView(withId(R.id.hints_and_solution_recycler_view)) .inRoot(isDialog()) .perform(scrollToPosition(/* position= */ solutionIndex * 2)) + testCoroutineDispatchers.runCurrent() onView(allOf(withId(R.id.reveal_solution_button), isDisplayed())) .inRoot(isDialog()) .check(matches(isDisplayed())) @@ -763,6 +779,7 @@ class StateFragmentLocalTest { onView(withId(R.id.hints_and_solution_recycler_view)) .inRoot(isDialog()) .perform(scrollToPosition(/* position= */ solutionIndex * 2)) + testCoroutineDispatchers.runCurrent() onView(allOf(withId(R.id.reveal_solution_button), isDisplayed())) .inRoot(isDialog()) .check(matches(isDisplayed())) @@ -786,9 +803,11 @@ class StateFragmentLocalTest { onView(withId(R.id.hints_and_solution_recycler_view)) .inRoot(isDialog()) .perform(scrollToPosition(/* position= */ solutionIndex * 2)) + testCoroutineDispatchers.runCurrent() onView(allOf(withId(R.id.reveal_solution_button), isDisplayed())) .inRoot(isDialog()) .perform(click()) + testCoroutineDispatchers.runCurrent() onView(withText("This will reveal the solution. Are you sure?")) .inRoot(isDialog()) @@ -1248,7 +1267,10 @@ class StateFragmentLocalTest { } // Go to previous state and then come back to current state - private fun moveToPreviousAndBackToCurrentState() { + private fun moveToPreviousAndBackToCurrentStateWithSubmitButton() { + // The previous navigation button is bundled with the submit button sometimes, and specifically + // for tests that are currently on a state with a submit button after the first state. + onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(SUBMIT_ANSWER_BUTTON)) onView(withId(R.id.previous_state_navigation_button)).perform(click()) testCoroutineDispatchers.runCurrent() onView(withId(R.id.state_recycler_view)).perform(scrollToViewType(NEXT_NAVIGATION_BUTTON)) From ba45fd923ee5373fbcbdce7bf4885972d9c7e832 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 20 Nov 2020 18:46:57 -0800 Subject: [PATCH 46/64] Lint fix. --- .../org/oppia/android/app/player/state/StateFragmentLocalTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 6b4938e7193..51f586f90f2 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -54,7 +54,6 @@ import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.CONTINUE_NAVIGATION_BUTTON import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.FRACTION_INPUT_INTERACTION import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.NEXT_NAVIGATION_BUTTON -import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.PREVIOUS_NAVIGATION_BUTTON import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.PREVIOUS_RESPONSES_HEADER import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.SELECTION_INTERACTION import org.oppia.android.app.player.state.itemviewmodel.StateItemViewModel.ViewType.SUBMIT_ANSWER_BUTTON From d7fd5bb6108a73340432a9e82c0f9dff2daf441b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 23 Nov 2020 13:51:41 -0800 Subject: [PATCH 47/64] Fix timing issues and JDK 9-specific regression. See comment thread in #1904 for more context. --- .../res/layout-land/submitted_answer_item.xml | 1 + .../main/res/layout/submitted_answer_item.xml | 1 + .../player/state/StateFragmentLocalTest.kt | 87 ++++++++++++++++--- 3 files changed, 75 insertions(+), 14 deletions(-) diff --git a/app/src/main/res/layout-land/submitted_answer_item.xml b/app/src/main/res/layout-land/submitted_answer_item.xml index be47a4839fb..ea3947a6437 100644 --- a/app/src/main/res/layout-land/submitted_answer_item.xml +++ b/app/src/main/res/layout-land/submitted_answer_item.xml @@ -20,6 +20,7 @@ , times: Int): ViewAssertion { + return matches( + object : TypeSafeMatcher() { + override fun describeTo(description: Description?) { + description + ?.appendDescriptionOf(matcher) + ?.appendText(" occurs times: $times in child views") + } + + override fun matchesSafely(view: View?): Boolean { + if (view !is ViewGroup) { + throw PerformException.Builder() + .withCause(IllegalStateException("Expected to match against view group, not: $view")) + .build() + } + val matchingCount = view.children.filter(matcher::matches).count() + if (matchingCount != times) { + throw PerformException.Builder() + .withActionDescription("Expected to match $matcher against $times children") + .withViewDescription("$view") + .withCause( + IllegalStateException("Matched $matchingCount times in $view (expected $times)") + ) + .build() + } + return true + } + }) + } + // TODO(#59): Figure out a way to reuse modules instead of needing to re-declare them. // TODO(#1675): Add NetworkModule once data module is migrated off of Moshi. @Singleton From 80a60398c47a0eeb42522f11e344f961da41b65a Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 23 Nov 2020 14:08:33 -0800 Subject: [PATCH 48/64] Restore workflow names + introduce test check. The new test check workflow will be a static job that will be required to pass. One failing test is being introduced to verify that this check fails as expected. The original workflow names are being restored so that they don't need to be renamed in GitHub settings (since that would introduce a discontinuity in CI service & require multiple migratiaon PRs to fix). --- .github/workflows/main.yml | 33 ++++++++++++++++--- .../player/state/StateFragmentLocalTest.kt | 5 +++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2e64e2b5e7d..b96e29b22f8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,10 @@ on: jobs: linters: name: Lint Tests - runs-on: ubuntu-18.04 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 @@ -44,7 +47,10 @@ jobs: robolectric_tests: name: Robolectric Tests (Non-App Modules) - runs-on: ubuntu-18.04 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 - uses: actions/cache@v2 @@ -98,7 +104,10 @@ jobs: app_tests: name: Robolectric Tests - App Module (Non-Flaky) - runs-on: ubuntu-18.04 + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 @@ -124,8 +133,11 @@ jobs: path: app/build/reports bazel_build_app: - name: Build Bazel Binary - runs-on: ubuntu-18.04 + name: Build Binary with Bazel + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 - name: Clone Oppia Bazel @@ -286,3 +298,14 @@ jobs: env: BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} + + # Reference: https://github.community/t/127354/7. + check_test_results: + name: Check Bazel Test Results + needs: bazel_run_test + if: ${{ always() }} + runs-on: ubuntu-18.04 + steps: + - name: Check tests passed + if: ${{ needs.bazel_run_test.result != 'success' }} + run: exit 1 diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 4a6d0f51b58..9c558e92544 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -256,6 +256,11 @@ class StateFragmentLocalTest { } } + @Test + fun testFailOnPurpose() { + throw AssertionError("Failed") + } + @Test fun testStateFragment_nextState_wait120seconds_canViewOneHint() { launchForExploration(FRACTIONS_EXPLORATION_ID_1).use { From 528bf6bc4b3e99d94bcf83572eb8906474ded555 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 23 Nov 2020 16:46:37 -0800 Subject: [PATCH 49/64] Update StateFragmentLocalTest.kt Remove fail-on-purpose test since it verified what it needed to: the new test status check job is working as expected. --- .../oppia/android/app/player/state/StateFragmentLocalTest.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index 9c558e92544..4a6d0f51b58 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -256,11 +256,6 @@ class StateFragmentLocalTest { } } - @Test - fun testFailOnPurpose() { - throw AssertionError("Failed") - } - @Test fun testStateFragment_nextState_wait120seconds_canViewOneHint() { launchForExploration(FRACTIONS_EXPLORATION_ID_1).use { From 062b34dc37ae9137bf386a372e8b5e924ffbcac5 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Wed, 9 Dec 2020 12:19:21 -0800 Subject: [PATCH 50/64] Address reviewer comments. --- .github/CODEOWNERS | 1 + .github/workflows/workflow_canceller.yml | 9 +++++++++ scripts/compute_affected_tests.sh | 8 ++++---- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 75bc528e7cd..c73cd3405c7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -13,6 +13,7 @@ # GitHub Actions & CI workflows. .github/*.yaml @BenHenning +.github/*.yml @BenHenning # Blanket codeowners # This is for the case when new files are created in any directories that aren't diff --git a/.github/workflows/workflow_canceller.yml b/.github/workflows/workflow_canceller.yml index b3402485e7a..fd6ac56313a 100644 --- a/.github/workflows/workflow_canceller.yml +++ b/.github/workflows/workflow_canceller.yml @@ -1,5 +1,13 @@ name: Automatic Workflow Canceller +# This workflow should be triggered in one of three situations: +# 1. Manual workflow dispatch via https://github.com/oppia/oppia-android/actions. +# 2. Upon creation of a PR & updates to that PR. +# 3. Whenever the develop branch is changed (e.g. after a PR is merged). +# +# Note that the action being used here automatically accounts for the current branch & the commit +# hash of the tip of the branch to ensure it doesn't cancel previous workflows that aren't related +# to the branch being evaluated. on: workflow_dispatch: pull_request: @@ -13,6 +21,7 @@ jobs: name: Cancel Previous Runs runs-on: ubuntu-18.04 steps: + # See https://github.com/styfle/cancel-workflow-action for details on this workflow. - uses: styfle/cancel-workflow-action@0.6.0 with: workflow_id: main.yml diff --git a/scripts/compute_affected_tests.sh b/scripts/compute_affected_tests.sh index 0b4990a47e0..e264b37d824 100755 --- a/scripts/compute_affected_tests.sh +++ b/scripts/compute_affected_tests.sh @@ -39,21 +39,21 @@ if [[ "$current_branch" != "develop" ]]; then # Filter all of the source files among those that are actually included in Bazel builds. changed_bazel_files=() - for changed_file in ${changed_files[@]}; do + for changed_file in "${changed_files[@]}"; do changed_bazel_files+=($($BAZEL_BINARY query --noshow_progress $changed_file 2> /dev/null)) done # Compute the list of affected tests based on source files. - source_affected_targets=$($BAZEL_BINARY query --noshow_progress --universe_scope=//... --order_output=no "kind(test, allrdeps(set(${changed_bazel_files[@]})))" 2>/dev/null) + source_affected_targets="$($BAZEL_BINARY query --noshow_progress --universe_scope=//... --order_output=no "kind(test, allrdeps(set(${changed_bazel_files[@]})))" 2>/dev/null)" # Compute the list of files to consider for BUILD-level changes (this uses the base file list as a # reference since Bazel's query won't find matching targets for utility bzl files that can still # affect the build). https://stackoverflow.com/a/44107086 for reference on changing case matching. shopt -s nocasematch changed_bazel_support_files=() - for changed_file in ${changed_files[@]}; do + for changed_file in "${changed_files[@]}"; do if [[ "$changed_file" =~ ^.+?\.bazel$ ]] || [[ "$changed_file" =~ ^.+?\.bzl$ ]] || [[ "$changed_file" == "WORKSPACE" ]]; then - changed_bazel_support_files+=($changed_file) + changed_bazel_support_files+=("$changed_file") fi done shopt -u nocasematch From 9530d12aa3cba11d1ab5d464109b89517178328f Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 15 Dec 2020 21:10:18 -0800 Subject: [PATCH 51/64] Fix most tests broken in Bazel after syncing. --- app/BUILD.bazel | 6 +-- domain/BUILD.bazel | 16 +++++++- ...enominatorEqualToRuleClassifierProvider.kt | 3 +- ...artExactlyEqualToRuleClassifierProvider.kt | 3 +- ...ntegerPartEqualToRuleClassifierProvider.kt | 3 +- ...sNoFractionalPartRuleClassifierProvider.kt | 3 +- ...sNumeratorEqualToRuleClassifierProvider.kt | 3 +- ...AndInSimplestFormRuleClassifierProvider.kt | 3 +- ...putIsEquivalentToRuleClassifierProvider.kt | 3 +- ...tIsExactlyEqualToRuleClassifierProvider.kt | 3 +- ...nputIsGreaterThanRuleClassifierProvider.kt | 3 +- ...onInputIsLessThanRuleClassifierProvider.kt | 3 +- ...tainsAtLeastOneOfRuleClassifierProvider.kt | 3 +- ...ntainAtLeastOneOfRuleClassifierProvider.kt | 3 +- ...ectionInputEqualsRuleClassifierProvider.kt | 3 +- ...tIsProperSubsetOfRuleClassifierProvider.kt | 3 +- ...ithUnitsIsEqualToRuleClassifierProvider.kt | 3 +- ...itsIsEquivalentToRuleClassifierProvider.kt | 3 +- ...aterThanOrEqualToRuleClassifierProvider.kt | 3 +- ...nputIsGreaterThanRuleClassifierProvider.kt | 3 +- ...nclusivelyBetweenRuleClassifierProvider.kt | 3 +- ...LessThanOrEqualToRuleClassifierProvider.kt | 3 +- ...icInputIsLessThanRuleClassifierProvider.kt | 3 +- ...IsWithinToleranceRuleClassifierProvider.kt | 3 +- .../RatioInputEqualsRuleClassifierProvider.kt | 3 +- ...sNumberOfTermsEqualToClassifierProvider.kt | 3 +- ...InputIsEquivalentRuleClassifierProvider.kt | 3 +- ...seSensitiveEqualsRuleClassifierProvider.kt | 3 +- ...tInputFuzzyEqualsRuleClassifierProvider.kt | 3 +- ...xtInputStartsWithRuleClassifierProvider.kt | 3 +- .../loguploader/FakeLogUploader.kt | 35 +++++++++++++++++ .../domain/oppialogger/OppiaLoggerTest.kt | 15 ++++---- .../analytics/AnalyticsControllerTest.kt | 16 ++++---- .../LogUploadWorkManagerInitializerTest.kt | 38 +------------------ .../loguploader/LogUploadWorkerTest.kt | 6 ++- 35 files changed, 130 insertions(+), 86 deletions(-) create mode 100644 domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt diff --git a/app/BUILD.bazel b/app/BUILD.bazel index 294d200cad4..ad0269475b5 100644 --- a/app/BUILD.bazel +++ b/app/BUILD.bazel @@ -1048,9 +1048,9 @@ app_test( # TODO(#973): Fix app module tests for Robolectric. app_test( - name = "NavigationDrawerTestActivityTest", - srcs = [test_with_resources("src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerTestActivityTest.kt")], - test_class = "org.oppia.android.app.testing.NavigationDrawerTestActivityTest", + name = "NavigationDrawerActivityTest", + srcs = [test_with_resources("src/sharedTest/java/org/oppia/android/app/testing/NavigationDrawerActivityTest.kt")], + test_class = "org.oppia.android.app.testing.NavigationDrawerActivityTest", deps = TEST_DEPS, ) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index e5a76799fdc..e318f0873e8 100644 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -10,7 +10,10 @@ load("//domain:domain_test.bzl", "domain_test") kt_android_library( name = "domain", - srcs = glob(["src/main/java/org/oppia/android/domain/**/*.kt"]), + srcs = glob( + ["src/main/java/org/oppia/android/domain/**/*.kt"], + exclude=["src/main/java/org/oppia/android/domain/testing/**/*.kt"] + ), assets = glob(["src/main/assets/**"]), assets_dir = "src/main/assets/", custom_package = "org.oppia.android.domain", @@ -23,6 +26,16 @@ kt_android_library( ], ) +kt_android_library( + name = "testing", + testonly = True, + srcs = glob(["src/main/java/org/oppia/android/domain/testing/**/*.kt"]), + deps = [ + ":domain", + artifact("androidx.work:work-runtime-ktx:2.4.0"), + ], +) + # TODO(#2143): Move InteractionObjectTestBuilder to a testing package outside the test folder. kt_android_library( name = "interaction_object_test_builder", @@ -39,6 +52,7 @@ TEST_DEPS = [ ":dagger", ":domain", ":interaction_object_test_builder", + ":testing", "//data:persistent_cache_store", "//model", "//testing", diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProvider.kt index 920d80da61f..0e64186bf88 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasDenominatorEqualToRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L55 */ -internal class FractionInputHasDenominatorEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputHasDenominatorEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeSingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProvider.kt index abd7a5e524d..0cf0436d126 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasFractionalPartExactlyEqualToRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L61 */ -internal class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProvider +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputHasFractionalPartExactlyEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProvider.kt index d24052e7e67..936de86e002 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasIntegerPartEqualToRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L48 */ -internal class FractionInputHasIntegerPartEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputHasIntegerPartEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeSingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProvider.kt index 53be10e46a0..58f9c867e79 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNoFractionalPartRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L58 */ -internal class FractionInputHasNoFractionalPartRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputHasNoFractionalPartRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.NoInputInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProvider.kt index c4b57344f10..6ac6548b17b 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputHasNumeratorEqualToRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L52 */ -internal class FractionInputHasNumeratorEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputHasNumeratorEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeSingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProvider.kt index bffab3f96d6..1a594f1e68b 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProvider.kt @@ -16,7 +16,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L32 */ -internal class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProvider +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputIsEquivalentToAndInSimplestFormRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProvider.kt index 3f327c293f3..2fb33b8a49e 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsEquivalentToRuleClassifierProvider.kt @@ -15,7 +15,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L29 */ -internal class FractionInputIsEquivalentToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputIsEquivalentToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProvider.kt index f6bf11e37c6..6d598462f21 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsExactlyEqualToRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L38 */ -internal class FractionInputIsExactlyEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputIsExactlyEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProvider.kt index 7f6134b77c2..b97634272a6 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsGreaterThanRuleClassifierProvider.kt @@ -14,7 +14,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L45 */ -internal class FractionInputIsGreaterThanRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputIsGreaterThanRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProvider.kt index 2af4756865e..7daa45360ee 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/fractioninput/FractionInputIsLessThanRuleClassifierProvider.kt @@ -14,7 +14,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/FractionInput/directives/fraction-input-rules.service.ts#L42 */ -internal class FractionInputIsLessThanRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class FractionInputIsLessThanRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProvider.kt index ccecf8cf291..970e1a039c2 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputContainsAtLeastOneOfRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/ItemSelectionInput/directives/item-selection-input-rules.service.ts#L32 */ -internal class ItemSelectionInputContainsAtLeastOneOfRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class ItemSelectionInputContainsAtLeastOneOfRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProvider.kt index 0b2ce625d99..4e060c308fb 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/ItemSelectionInput/directives/item-selection-input-rules.service.ts#L41 */ -internal class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProvider +// TODO(#1580): Re-restrict access using Bazel visibilities +class ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProvider.kt index 4323babbcbf..2a0be24f078 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputEqualsRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/ItemSelectionInput/directives/item-selection-input-rules.service.ts#L24 */ -internal class ItemSelectionInputEqualsRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class ItemSelectionInputEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProvider.kt index 6e773b1ea7b..c89b1d07743 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputIsProperSubsetOfRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/ItemSelectionInput/directives/item-selection-input-rules.service.ts#L50 */ -internal class ItemSelectionInputIsProperSubsetOfRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class ItemSelectionInputIsProperSubsetOfRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProvider.kt index 2d041af1383..b9c3fc9647f 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEqualToRuleClassifierProvider.kt @@ -15,7 +15,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumberWithUnits/directives/number-with-units-rules.service.ts#L34 */ -internal class NumberWithUnitsIsEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumberWithUnitsIsEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProvider.kt index e5d66332c9d..2572709908f 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numberwithunits/NumberWithUnitsIsEquivalentToRuleClassifierProvider.kt @@ -15,7 +15,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumberWithUnits/directives/number-with-units-rules.service.ts#L48 */ -internal class NumberWithUnitsIsEquivalentToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumberWithUnitsIsEquivalentToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProvider.kt index 6416890a774..b6b2d3877af 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanOrEqualToRuleClassifierProvider.kt @@ -11,7 +11,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L33 */ -internal class NumericInputIsGreaterThanOrEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumericInputIsGreaterThanOrEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProvider.kt index 981f9064ae5..d1980129de1 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsGreaterThanRuleClassifierProvider.kt @@ -11,7 +11,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L27 */ -internal class NumericInputIsGreaterThanRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumericInputIsGreaterThanRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProvider.kt index 3205c34c470..942f774aeee 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsInclusivelyBetweenRuleClassifierProvider.kt @@ -12,7 +12,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L36 */ -internal class NumericInputIsInclusivelyBetweenRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumericInputIsInclusivelyBetweenRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.DoubleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProvider.kt index 5685ae912be..122139a32c2 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanOrEqualToRuleClassifierProvider.kt @@ -11,7 +11,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L30 */ -internal class NumericInputIsLessThanOrEqualToRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumericInputIsLessThanOrEqualToRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProvider.kt index 2d737b89b3a..dfef211d916 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsLessThanRuleClassifierProvider.kt @@ -11,7 +11,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L24 */ -internal class NumericInputIsLessThanRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumericInputIsLessThanRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProvider.kt index 3097fe02137..63c38aa8116 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/numericinput/NumericInputIsWithinToleranceRuleClassifierProvider.kt @@ -12,7 +12,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/NumericInput/directives/numeric-input-rules.service.ts#L41 */ -internal class NumericInputIsWithinToleranceRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class NumericInputIsWithinToleranceRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.DoubleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProvider.kt index e27bb871863..cd25fb88cbf 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputEqualsRuleClassifierProvider.kt @@ -11,7 +11,8 @@ import javax.inject.Inject * Provider for a classifier that determines whether two object are equal per the ratio input * interaction. */ -internal class RatioInputEqualsRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class RatioInputEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProvider.kt index e7428765bdf..ef0697a3b68 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputHasNumberOfTermsEqualToClassifierProvider.kt @@ -10,7 +10,8 @@ import javax.inject.Inject /** * Provider for a classifier that determines whether two object have an equal number of terms. */ -internal class RatioInputHasNumberOfTermsEqualToClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class RatioInputHasNumberOfTermsEqualToClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.MultiTypeSingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProvider.kt index 2c6f24b7b52..3cdf2010e15 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/ratioinput/RatioInputIsEquivalentRuleClassifierProvider.kt @@ -12,7 +12,8 @@ import javax.inject.Inject * Provider for a classifier that determines whether two object are equal by converting them into * their lowest form as per the ratio input interaction. */ -internal class RatioInputIsEquivalentRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class RatioInputIsEquivalentRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputCaseSensitiveEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputCaseSensitiveEqualsRuleClassifierProvider.kt index 61646b51790..ac9245f0ab3 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputCaseSensitiveEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputCaseSensitiveEqualsRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/TextInput/directives/text-input-rules.service.ts#L59 */ -internal class TextInputCaseSensitiveEqualsRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class TextInputCaseSensitiveEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProvider.kt index 7cef1505cdb..45a840cf78f 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputFuzzyEqualsRuleClassifierProvider.kt @@ -12,7 +12,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/TextInput/directives/text-input-rules.service.ts#L29. */ -internal class TextInputFuzzyEqualsRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class TextInputFuzzyEqualsRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProvider.kt b/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProvider.kt index e1bf898eca2..5c7869994d9 100644 --- a/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProvider.kt +++ b/domain/src/main/java/org/oppia/android/domain/classify/rules/textinput/TextInputStartsWithRuleClassifierProvider.kt @@ -13,7 +13,8 @@ import javax.inject.Inject * * https://github.com/oppia/oppia/blob/37285a/extensions/interactions/TextInput/directives/text-input-rules.service.ts#L64 */ -internal class TextInputStartsWithRuleClassifierProvider @Inject constructor( +// TODO(#1580): Re-restrict access using Bazel visibilities +class TextInputStartsWithRuleClassifierProvider @Inject constructor( private val classifierFactory: GenericRuleClassifier.Factory ) : RuleClassifierProvider, GenericRuleClassifier.SingleInputMatcher { diff --git a/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt b/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt new file mode 100644 index 00000000000..e9c399663f9 --- /dev/null +++ b/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt @@ -0,0 +1,35 @@ +package org.oppia.android.domain.testing.oppialogger.loguploader + +import androidx.work.PeriodicWorkRequest +import androidx.work.WorkManager +import org.oppia.android.util.logging.LogUploader +import java.util.UUID +import javax.inject.Inject +import javax.inject.Singleton + +/** A test specific fake for the log uploader. */ +@Singleton +class FakeLogUploader @Inject constructor(): LogUploader { + private val eventRequestIdList = mutableListOf() + private val exceptionRequestIdList = mutableListOf() + + override fun enqueueWorkRequestForEvents( + workManager: WorkManager, + workRequest: PeriodicWorkRequest + ) { + eventRequestIdList.add(workRequest.id) + } + + override fun enqueueWorkRequestForExceptions( + workManager: WorkManager, + workRequest: PeriodicWorkRequest + ) { + exceptionRequestIdList.add(workRequest.id) + } + + /** Returns the most recent work request id that's stored in the [eventRequestIdList]. */ + fun getMostRecentEventRequestId() = eventRequestIdList.last() + + /** Returns the most recent work request id that's stored in the [exceptionRequestIdList]. */ + fun getMostRecentExceptionRequestId() = exceptionRequestIdList.last() +} diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt index 30de9feba66..8b1de99fd70 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt @@ -13,13 +13,6 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog -import org.oppia.android.domain.oppialogger.analytics.TEST_EXPLORATION_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_QUESTION_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_SKILL_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_SKILL_LIST_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_STORY_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_SUB_TOPIC_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_TOPIC_ID import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule import org.oppia.android.util.logging.EnableConsoleLog @@ -31,6 +24,14 @@ import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton +private const val TEST_TOPIC_ID = "test_topicId" +private const val TEST_STORY_ID = "test_storyId" +private const val TEST_EXPLORATION_ID = "test_explorationId" +private const val TEST_QUESTION_ID = "test_questionId" +private const val TEST_SKILL_ID = "test_skillId" +private const val TEST_SKILL_LIST_ID = "test_skillListId" +private const val TEST_SUB_TOPIC_ID = 1 + @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt index 9d6bd5a0cd2..8afb1abf901 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/analytics/AnalyticsControllerTest.kt @@ -53,14 +53,14 @@ import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton -const val TEST_TIMESTAMP = 1556094120000 -const val TEST_TOPIC_ID = "test_topicId" -const val TEST_STORY_ID = "test_storyId" -const val TEST_EXPLORATION_ID = "test_explorationId" -const val TEST_QUESTION_ID = "test_questionId" -const val TEST_SKILL_ID = "test_skillId" -const val TEST_SKILL_LIST_ID = "test_skillListId" -const val TEST_SUB_TOPIC_ID = 1 +private const val TEST_TIMESTAMP = 1556094120000 +private const val TEST_TOPIC_ID = "test_topicId" +private const val TEST_STORY_ID = "test_storyId" +private const val TEST_EXPLORATION_ID = "test_explorationId" +private const val TEST_QUESTION_ID = "test_questionId" +private const val TEST_SKILL_ID = "test_skillId" +private const val TEST_SKILL_LIST_ID = "test_skillListId" +private const val TEST_SUB_TOPIC_ID = 1 @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkManagerInitializerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkManagerInitializerTest.kt index 3056ca454e1..d0f6ba4338e 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkManagerInitializerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkManagerInitializerTest.kt @@ -9,8 +9,6 @@ import androidx.work.Configuration import androidx.work.Constraints import androidx.work.Data import androidx.work.NetworkType -import androidx.work.PeriodicWorkRequest -import androidx.work.WorkManager import androidx.work.testing.SynchronousExecutor import androidx.work.testing.WorkManagerTestInitHelper import com.google.common.truth.Truth.assertThat @@ -25,8 +23,8 @@ import org.junit.runner.RunWith import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.OppiaLogger -import org.oppia.android.domain.oppialogger.analytics.AnalyticsController import org.oppia.android.domain.oppialogger.exceptions.ExceptionsController +import org.oppia.android.domain.testing.oppialogger.loguploader.FakeLogUploader import org.oppia.android.testing.FakeEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.TestCoroutineDispatchers @@ -41,10 +39,8 @@ import org.oppia.android.util.logging.LogUploader import org.oppia.android.util.networking.NetworkConnectionUtil import org.robolectric.annotation.Config import org.robolectric.annotation.LooperMode -import java.util.UUID import javax.inject.Inject import javax.inject.Singleton -import kotlin.collections.last @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @@ -57,9 +53,6 @@ class LogUploadWorkManagerInitializerTest { @Inject lateinit var logUploadWorkManagerInitializer: LogUploadWorkManagerInitializer - @Inject - lateinit var analyticsController: AnalyticsController - @Inject lateinit var exceptionsController: ExceptionsController @@ -224,32 +217,3 @@ class LogUploadWorkManagerInitializerTest { fun inject(logUploadWorkRequestTest: LogUploadWorkManagerInitializerTest) } } - -/** A test specific fake for the log uploader. */ -@Singleton -class FakeLogUploader @Inject constructor() : - LogUploader { - - private val eventRequestIdList = mutableListOf() - private val exceptionRequestIdList = mutableListOf() - - override fun enqueueWorkRequestForEvents( - workManager: WorkManager, - workRequest: PeriodicWorkRequest - ) { - eventRequestIdList.add(workRequest.id) - } - - override fun enqueueWorkRequestForExceptions( - workManager: WorkManager, - workRequest: PeriodicWorkRequest - ) { - exceptionRequestIdList.add(workRequest.id) - } - - /** Returns the most recent work request id that's stored in the [eventRequestIdList]. */ - fun getMostRecentEventRequestId() = eventRequestIdList.last() - - /** Returns the most recent work request id that's stored in the [exceptionRequestIdList]. */ - fun getMostRecentExceptionRequestId() = exceptionRequestIdList.last() -} diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt index 6bc1591211e..b81b1e2eb49 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt @@ -27,9 +27,8 @@ import org.oppia.android.domain.oppialogger.EventLogStorageCacheSize import org.oppia.android.domain.oppialogger.ExceptionLogStorageCacheSize import org.oppia.android.domain.oppialogger.OppiaLogger import org.oppia.android.domain.oppialogger.analytics.AnalyticsController -import org.oppia.android.domain.oppialogger.analytics.TEST_TIMESTAMP -import org.oppia.android.domain.oppialogger.analytics.TEST_TOPIC_ID import org.oppia.android.domain.oppialogger.exceptions.ExceptionsController +import org.oppia.android.domain.testing.oppialogger.loguploader.FakeLogUploader import org.oppia.android.testing.FakeEventLogger import org.oppia.android.testing.FakeExceptionLogger import org.oppia.android.testing.TestCoroutineDispatchers @@ -47,6 +46,9 @@ import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton +private const val TEST_TIMESTAMP = 1556094120000 +private const val TEST_TOPIC_ID = "test_topicId" + @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) From a3fa326c91f135eb1b5d364468b913479e1c9490 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 15 Dec 2020 21:50:03 -0800 Subject: [PATCH 52/64] Gitignore + fix broken test. The test failure here only happens when using JDK9+ (which doesn't happen in the Gradle world, or on CI). The .gitignore is since we can't yet specify a .bazelproject in a shareable way. --- .gitignore | 1 + .../loguploader/LogUploadWorkerTest.kt | 29 +++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index fe10fc61e64..7575c3465f8 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ gradlew.bat !*.secret config/oppia-dev-workflow-remote-cache-credentials.json bazel-* +.bazelproject diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt index b81b1e2eb49..ef0f74dbcfd 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt @@ -157,13 +157,32 @@ class LogUploadWorkerTest { .build() workManager.enqueue(request) testCoroutineDispatchers.runCurrent() - val workInfo = workManager.getWorkInfoById(request.id) - val exceptionGot = fakeExceptionLogger.getMostRecentException() + val workInfo = workManager.getWorkInfoById(request.id) + val loggedException = fakeExceptionLogger.getMostRecentException() + val loggedExceptionStackTraceElems = loggedException.stackTrace.extractRelevantDetails() + val expectedExceptionStackTraceElems = exception.stackTrace.extractRelevantDetails() assertThat(workInfo.get().state).isEqualTo(WorkInfo.State.SUCCEEDED) - assertThat(exceptionGot.message).isEqualTo("TEST") - assertThat(exceptionGot.stackTrace).isEqualTo(exception.stackTrace) - assertThat(exceptionGot.cause).isEqualTo(null) + assertThat(loggedException.message).isEqualTo("TEST") + assertThat(loggedException.cause).isEqualTo(null) + // The following can't be an exact match for the stack trace since new properties are added to + // stack trace elements in newer versions of Java (such as module name). + assertThat(loggedExceptionStackTraceElems).isEqualTo(expectedExceptionStackTraceElems) + } + + /** + * Returns a list of lists of each relevant element of a [StackTraceElement] to be used for + * comparison in a way that's consistent across JDK versions. + */ + private fun Array.extractRelevantDetails(): List> { + return this.map { element -> + return@map listOf( + element.fileName, + element.methodName, + element.lineNumber, + element.className + ) + } } private fun setUpTestApplicationComponent() { From 5908e770af99a81e7b76728b4813aa34d323e364 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Tue, 15 Dec 2020 21:56:37 -0800 Subject: [PATCH 53/64] Lint fixes. --- .../testing/oppialogger/loguploader/FakeLogUploader.kt | 10 +++++----- .../oppialogger/loguploader/LogUploadWorkerTest.kt | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt b/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt index e9c399663f9..b2a02324827 100644 --- a/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt +++ b/domain/src/main/java/org/oppia/android/domain/testing/oppialogger/loguploader/FakeLogUploader.kt @@ -9,20 +9,20 @@ import javax.inject.Singleton /** A test specific fake for the log uploader. */ @Singleton -class FakeLogUploader @Inject constructor(): LogUploader { +class FakeLogUploader @Inject constructor() : LogUploader { private val eventRequestIdList = mutableListOf() private val exceptionRequestIdList = mutableListOf() override fun enqueueWorkRequestForEvents( - workManager: WorkManager, - workRequest: PeriodicWorkRequest + workManager: WorkManager, + workRequest: PeriodicWorkRequest ) { eventRequestIdList.add(workRequest.id) } override fun enqueueWorkRequestForExceptions( - workManager: WorkManager, - workRequest: PeriodicWorkRequest + workManager: WorkManager, + workRequest: PeriodicWorkRequest ) { exceptionRequestIdList.add(workRequest.id) } diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt index ef0f74dbcfd..d190118623c 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/loguploader/LogUploadWorkerTest.kt @@ -177,10 +177,10 @@ class LogUploadWorkerTest { private fun Array.extractRelevantDetails(): List> { return this.map { element -> return@map listOf( - element.fileName, - element.methodName, - element.lineNumber, - element.className + element.fileName, + element.methodName, + element.lineNumber, + element.className ) } } From 654c27a724b950038ac53b6e6e27112dd6893e2a Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 7 Jan 2021 15:44:13 -0800 Subject: [PATCH 54/64] Post-merge clean-up. --- .../oppia/android/domain/oppialogger/OppiaLoggerTest.kt | 8 -------- 1 file changed, 8 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt index eaca5c7c98d..6fa6b2b6701 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt @@ -32,14 +32,6 @@ import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton -private const val TEST_TOPIC_ID = "test_topicId" -private const val TEST_STORY_ID = "test_storyId" -private const val TEST_EXPLORATION_ID = "test_explorationId" -private const val TEST_QUESTION_ID = "test_questionId" -private const val TEST_SKILL_ID = "test_skillId" -private const val TEST_SKILL_LIST_ID = "test_skillListId" -private const val TEST_SUB_TOPIC_ID = 1 - @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) From 32a6009f55f11641f20933fe77a94c12e55e3691 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 7 Jan 2021 17:11:25 -0800 Subject: [PATCH 55/64] Fix broken post-merge test. --- .../android/domain/oppialogger/OppiaLoggerTest.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt index 6fa6b2b6701..2bc45e1b733 100644 --- a/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt +++ b/domain/src/test/java/org/oppia/android/domain/oppialogger/OppiaLoggerTest.kt @@ -13,13 +13,6 @@ import org.junit.Before import org.junit.Test import org.junit.runner.RunWith import org.oppia.android.app.model.EventLog -import org.oppia.android.domain.oppialogger.analytics.TEST_EXPLORATION_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_QUESTION_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_SKILL_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_SKILL_LIST_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_STORY_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_SUB_TOPIC_ID -import org.oppia.android.domain.oppialogger.analytics.TEST_TOPIC_ID import org.oppia.android.testing.RobolectricModule import org.oppia.android.testing.TestDispatcherModule import org.oppia.android.testing.TestLogReportingModule @@ -32,6 +25,14 @@ import org.robolectric.annotation.LooperMode import javax.inject.Inject import javax.inject.Singleton +private const val TEST_TOPIC_ID = "test_topicId" +private const val TEST_STORY_ID = "test_storyId" +private const val TEST_EXPLORATION_ID = "test_explorationId" +private const val TEST_QUESTION_ID = "test_questionId" +private const val TEST_SKILL_ID = "test_skillId" +private const val TEST_SKILL_LIST_ID = "test_skillListId" +private const val TEST_SUB_TOPIC_ID = 1 + @RunWith(AndroidJUnit4::class) @LooperMode(LooperMode.Mode.PAUSED) @Config(manifest = Config.NONE) From f3cb6f56541e1d6c8c4fc9082b0464ae9581403a Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 7 Jan 2021 23:20:50 -0800 Subject: [PATCH 56/64] Remove unnecessary codeowners per earlier codeowners setup. --- .github/CODEOWNERS | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6b00aaec690..f8172dfdf16 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,10 +11,6 @@ # (See oppia/#10250 for an example.) Please make sure to restore ownership after # the above date passes. -# GitHub Actions & CI workflows. -.github/*.yaml @BenHenning -.github/*.yml @BenHenning - # Blanket codeowners # This is for the case when new files are created in any directories that aren't # covered as a whole, since in these cases, codeowners are not recognized for From 8d4eb873ca69821cb735700e5d1a96d52811f084 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 7 Jan 2021 23:23:42 -0800 Subject: [PATCH 57/64] Fix ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest. --- domain/BUILD.bazel | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index efda03a6067..f43696b92c5 100755 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -298,6 +298,15 @@ domain_test( deps = TEST_DEPS, ) +domain_test( + name = "ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest", + srcs = [ + "src/test/java/org/oppia/android/domain/classify/rules/itemselectioninput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt", + ], + test_class = "org.oppia.android.domain.classify.rules.itemselectioninput.ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest", + deps = TEST_DEPS, +) + domain_test( name = "MultipleChoiceInputEqualsRuleClassifierProviderTest", srcs = [ @@ -343,15 +352,6 @@ domain_test( deps = TEST_DEPS, ) -domain_test( - name = "ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest", - srcs = [ - "src/test/java/org/oppia/android/domain/classify/rules/textinput/ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest.kt", - ], - test_class = "org.oppia.android.domain.classify.rules.textinput.ItemSelectionInputDoesNotContainAtLeastOneOfRuleClassifierProviderTest", - deps = TEST_DEPS, -) - domain_test( name = "TextInputEqualsRuleClassifierProviderTest", srcs = [ From 59268611867d2db6bb12700a3c5a2cd18d62b081 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 7 Jan 2021 23:52:19 -0800 Subject: [PATCH 58/64] Disable image region selection tests. These tests can't correctly pass on Robolectric until #1611 is fixed, so disabling them for the time being to avoid the image loading flake happening on CI (but not locally). Note that chances are a fix will still be needed for the flake, but that can be addressed later. --- .../android/app/player/state/StateFragmentTest.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt index 4db6235e830..d7fbe92e71e 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt @@ -582,6 +582,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_submitButtonDisabled() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() @@ -595,7 +596,7 @@ class StateFragmentTest { @Test @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. - fun loadImageRegion_defaultRegionClick_defaultRegionClicked_submitButtonDisabled() { + fun testStateFragment_loadImageRegion_defaultRegionClick_defRegionClicked_submitButtonDisabled() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() @@ -608,6 +609,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_submitButtonEnabled() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() @@ -621,6 +623,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_correctFeedback() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() @@ -639,6 +642,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_correctAnswer() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() @@ -657,6 +661,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_clickedRegion6_region6Clicked_continueButtonIsDisplayed() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() @@ -671,7 +676,8 @@ class StateFragmentTest { } @Test - fun loadImageRegion_clickRegion6_clickedRegion5_region5Clicked_correctFeedback() { + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. + fun testStateFragment_loadImageRegion_clickRegion6_clickedRegion5_clickRegion5_correctFeedback() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() waitForImageViewInteractionToFullyLoad() From b4cd6b464a002a6687f69ff8d1dc590ef2e95e44 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Fri, 8 Jan 2021 00:28:48 -0800 Subject: [PATCH 59/64] Disable 2 previously missed tests. --- .../org/oppia/android/app/player/state/StateFragmentTest.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt index d7fbe92e71e..2acd1babf49 100644 --- a/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt +++ b/app/src/sharedTest/java/org/oppia/android/app/player/state/StateFragmentTest.kt @@ -551,6 +551,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_clickRegion6_submitButtonClickable() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() @@ -564,6 +565,7 @@ class StateFragmentTest { } @Test + @RunOn(TestPlatform.ESPRESSO) // TODO(#1611): Enable for Robolectric. fun testStateFragment_loadImageRegion_clickRegion6_clickSubmit_receivesCorrectFeedback() { launchForExploration(TEST_EXPLORATION_ID_5).use { startPlayingExploration() From eae966094f65539c8bba4472425794d3c8b3c2f7 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 8 Feb 2021 14:45:10 -0800 Subject: [PATCH 60/64] Post-merge lint fix. --- .../org/oppia/android/app/player/state/StateFragmentLocalTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt index cacad853d20..0fc83861a78 100644 --- a/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt +++ b/app/src/test/java/org/oppia/android/app/player/state/StateFragmentLocalTest.kt @@ -21,7 +21,6 @@ import androidx.test.espresso.assertion.ViewAssertions.matches import androidx.test.espresso.contrib.RecyclerViewActions.scrollToHolder import androidx.test.espresso.contrib.RecyclerViewActions.scrollToPosition import androidx.test.espresso.matcher.RootMatchers.isDialog -import androidx.test.espresso.matcher.ViewMatchers.hasChildCount import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.isRoot From a8bd5b371a537aa3253a4d5443baa6c151b9077b Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 8 Feb 2021 16:43:32 -0800 Subject: [PATCH 61/64] Add missing dependency. Verified all tests build & pass both for JDK 9 & 11. Hopefully they will work as expected on CI. --- testing/BUILD.bazel | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 5ba2534e179..1491038f0c0 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -20,6 +20,7 @@ kt_android_library( ":dagger", "//domain", "//utility", + artifact("nl.dionsegijn:konfetti"), artifact("org.jetbrains.kotlinx:kotlinx-coroutines-test"), artifact("org.robolectric:robolectric"), artifact("org.jetbrains.kotlin:kotlin-reflect"), @@ -84,9 +85,9 @@ testing_test( kt_android_library( name = "assertion_helpers", + testonly = True, srcs = ["src/main/java/org/oppia/android/testing/AssertionHelpers.kt"], visibility = ["//visibility:public"], - testonly = True, deps = [ artifact("org.jetbrains.kotlin:kotlin-reflect"), artifact("junit:junit:4.12"), From 33d4c379917cef2f6784538cebace92e1435d47f Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Mon, 8 Feb 2021 16:55:50 -0800 Subject: [PATCH 62/64] Add missing codeowners for new files. --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 54596a3ba2a..5c57263b1c7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -45,6 +45,10 @@ gradlew.bat @BenHenning /.github/*.md @BenHenning /.github/ISSUE_TEMPLATE @BenHenning +# Git secret files & related configurations. +/.gitsecret/ @BenHenning +*.secret @BenHenning + # CI configuration. /.github/workflows/ @BenHenning From b44ae3abddcbfa6fa295e711f3dde8efca44fa84 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 11 Feb 2021 15:09:37 -0800 Subject: [PATCH 63/64] Post-merge fixes. This fixes some tests that were broken after recent PRs, and fixed a visibility error introduced in #2663. --- domain/BUILD.bazel | 9 +-------- testing/BUILD.bazel | 8 ++++++++ third_party/BUILD.bazel | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/domain/BUILD.bazel b/domain/BUILD.bazel index cb5c9f56c42..aebc7016253 100755 --- a/domain/BUILD.bazel +++ b/domain/BUILD.bazel @@ -31,7 +31,7 @@ kt_android_library( srcs = glob(["src/main/java/org/oppia/android/domain/testing/**/*.kt"]), deps = [ ":domain", - artifact("androidx.work:work-runtime-ktx:2.4.0"), + "//third_party:androidx_work_work-runtime-ktx", ], ) @@ -456,13 +456,6 @@ domain_test( deps = TEST_DEPS, ) -domain_test( - name = "StoryProgressTestHelperTest", - srcs = ["src/test/java/org/oppia/android/domain/topic/StoryProgressTestHelperTest.kt"], - test_class = "org.oppia.android.domain.topic.StoryProgressTestHelperTest", - deps = TEST_DEPS, -) - domain_test( name = "TopicControllerTest", srcs = ["src/test/java/org/oppia/android/domain/topic/TopicControllerTest.kt"], diff --git a/testing/BUILD.bazel b/testing/BUILD.bazel index 02928f48dce..2ad57cd6a11 100644 --- a/testing/BUILD.bazel +++ b/testing/BUILD.bazel @@ -11,6 +11,7 @@ load("//testing:testing_test.bzl", "testing_test") # Library for general-purpose testing fakes. kt_android_library( name = "testing", + testonly = True, srcs = glob(["src/main/java/org/oppia/android/testing/**/*.kt"]), custom_package = "org.oppia.android.testing", manifest = "src/main/AndroidManifest.xml", @@ -83,6 +84,13 @@ testing_test( deps = TEST_DEPS, ) +testing_test( + name = "StoryProgressTestHelperTest", + srcs = ["src/test/java/org/oppia/android/testing/story/StoryProgressTestHelperTest.kt"], + test_class = "org.oppia.android.testing.story.StoryProgressTestHelperTest", + deps = TEST_DEPS, +) + testing_test( name = "FakeOppiaClockTest", srcs = ["src/test/java/org/oppia/android/testing/time/FakeOppiaClockTest.kt"], diff --git a/third_party/BUILD.bazel b/third_party/BUILD.bazel index 159685a3c55..7fcf410315b 100644 --- a/third_party/BUILD.bazel +++ b/third_party/BUILD.bazel @@ -46,6 +46,7 @@ android_library( android_library( name = "robolectric_android-all", + visibility = ["//visibility:public"], exports = [ "@robolectric//bazel:android-all", ], From 1a3f4e94ce3e1ed0b1774ff8035500b73e028aa6 Mon Sep 17 00:00:00 2001 From: Ben Henning Date: Thu, 11 Feb 2021 15:12:12 -0800 Subject: [PATCH 64/64] Move Bazel tests to new workflow. This will make it easier to restart failures without having to also restart unrelated tests. --- .github/workflows/main.yml | 106 --------------------------- .github/workflows/unit_tests.yml | 118 +++++++++++++++++++++++++++++++ 2 files changed, 118 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/unit_tests.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 71bb1893852..689631594ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -221,109 +221,3 @@ jobs: with: name: oppia-bazel-apk path: /home/runner/work/oppia-android/oppia-android/oppia.apk - - bazel_compute_affected_targets: - name: Compute affected tests - runs-on: ubuntu-18.04 - outputs: - matrix: ${{ steps.compute-test-matrix-from-affected.outputs.matrix || steps.compute-test-matrix-from-all.outputs.matrix }} - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Clone Oppia Bazel - run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel - - name: Unzip Bazel binary - run: | - cd $HOME/oppia-bazel - unzip bazel-build.zip - cd $GITHUB_WORKSPACE - chmod a+x $HOME/oppia-bazel/bazel - - name: Compute test matrix based on affected targets - id: compute-test-matrix-from-affected - if: "!contains(github.event.pull_request.title, '[RunAllTests]')" - # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly - # comma-separated list of test targets for the matrix. - run: | - TEST_TARGET_LIST=$(bash ./scripts/compute_affected_tests.sh $HOME/oppia-bazel/bazel | sed 's/^\|$/"/g' | paste -sd, -) - echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" - echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" - - name: Compute test matrix based on all tests - id: compute-test-matrix-from-all - if: "contains(github.event.pull_request.title, '[RunAllTests]')" - run: | - TEST_TARGET_LIST=$($HOME/oppia-bazel/bazel query "kind(test, //...)" | sed 's/^\|$/"/g' | paste -sd, -) - echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" - echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" - - bazel_run_test: - name: Run Bazel Test - needs: bazel_compute_affected_targets - runs-on: ubuntu-18.04 - strategy: - fail-fast: false - matrix: ${{fromJson(needs.bazel_compute_affected_targets.outputs.matrix)}} - steps: - - uses: actions/checkout@v2 - - name: Clone Oppia Bazel - run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel - - name: Set up JDK 9 - uses: actions/setup-java@v1 - with: - java-version: 9 - - name: Extract Android tools - run: | - mkdir -p $GITHUB_WORKSPACE/tmp/android_tools - cd $HOME/oppia-bazel - unzip bazel-tools.zip - tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools - # See explanation in bazel_build_app for how this is installed. - - name: Install git-secret (non-fork only) - if: github.repository == 'oppia/oppia-android' - shell: bash - run: | - cd $HOME - mkdir -p $HOME/gitsecret - git clone https://github.com/sobolevn/git-secret.git git-secret - cd git-secret && make build - PREFIX="$HOME/gitsecret" make install - echo "$HOME/gitsecret" >> $GITHUB_PATH - echo "$HOME/gitsecret/bin" >> $GITHUB_PATH - - name: Decrypt secrets (non-fork only) - if: github.repository == 'oppia/oppia-android' - env: - GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} - run: | - cd $HOME - # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! - echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg - gpg --import ./git_secret_private_key.gpg - cd $GITHUB_WORKSPACE - git secret reveal - - name: Unzip Bazel binary - run: | - cd $HOME/oppia-bazel - unzip bazel-build.zip - cd $GITHUB_WORKSPACE - chmod a+x $HOME/oppia-bazel/bazel - - name: Run Oppia Test (with caching, non-fork only) - if: github.repository == 'oppia/oppia-android' - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} - - name: Run Oppia Test (without caching, fork only) - if: github.repository != 'oppia/oppia-android' - env: - BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} - run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} - - # Reference: https://github.community/t/127354/7. - check_test_results: - name: Check Bazel Test Results - needs: bazel_run_test - if: ${{ always() }} - runs-on: ubuntu-18.04 - steps: - - name: Check tests passed - if: ${{ needs.bazel_run_test.result != 'success' }} - run: exit 1 diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml new file mode 100644 index 00000000000..fa5a270d9e9 --- /dev/null +++ b/.github/workflows/unit_tests.yml @@ -0,0 +1,118 @@ +name: Unit Tests (Robolectric - Bazel) + +# Controls when the action will run. Triggers the workflow on pull request +# events or push events in the develop branch. +on: + workflow_dispatch: + pull_request: + push: + branches: + # Push events on develop branch + - develop + +jobs: + bazel_compute_affected_targets: + name: Compute affected tests + runs-on: ubuntu-18.04 + outputs: + matrix: ${{ steps.compute-test-matrix-from-affected.outputs.matrix || steps.compute-test-matrix-from-all.outputs.matrix }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Clone Oppia Bazel + run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel + - name: Unzip Bazel binary + run: | + cd $HOME/oppia-bazel + unzip bazel-build.zip + cd $GITHUB_WORKSPACE + chmod a+x $HOME/oppia-bazel/bazel + - name: Compute test matrix based on affected targets + id: compute-test-matrix-from-affected + if: "!contains(github.event.pull_request.title, '[RunAllTests]')" + # https://unix.stackexchange.com/a/338124 for reference on creating a JSON-friendly + # comma-separated list of test targets for the matrix. + run: | + TEST_TARGET_LIST=$(bash ./scripts/compute_affected_tests.sh $HOME/oppia-bazel/bazel | sed 's/^\|$/"/g' | paste -sd, -) + echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" + echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" + - name: Compute test matrix based on all tests + id: compute-test-matrix-from-all + if: "contains(github.event.pull_request.title, '[RunAllTests]')" + run: | + TEST_TARGET_LIST=$($HOME/oppia-bazel/bazel query "kind(test, //...)" | sed 's/^\|$/"/g' | paste -sd, -) + echo "Affected tests (note that this might be all tests if on the develop branch): $TEST_TARGET_LIST" + echo "::set-output name=matrix::{\"test-target\":[$TEST_TARGET_LIST]}" + + bazel_run_test: + name: Run Bazel Test + needs: bazel_compute_affected_targets + runs-on: ubuntu-18.04 + strategy: + fail-fast: false + matrix: ${{fromJson(needs.bazel_compute_affected_targets.outputs.matrix)}} + steps: + - uses: actions/checkout@v2 + - name: Clone Oppia Bazel + run: git clone https://github.com/oppia/bazel.git $HOME/oppia-bazel + - name: Set up JDK 9 + uses: actions/setup-java@v1 + with: + java-version: 9 + - name: Extract Android tools + run: | + mkdir -p $GITHUB_WORKSPACE/tmp/android_tools + cd $HOME/oppia-bazel + unzip bazel-tools.zip + tar -xf $HOME/oppia-bazel/android_tools.tar.gz -C $GITHUB_WORKSPACE/tmp/android_tools + # See explanation in bazel_build_app for how this is installed. + - name: Install git-secret (non-fork only) + if: github.repository == 'oppia/oppia-android' + shell: bash + run: | + cd $HOME + mkdir -p $HOME/gitsecret + git clone https://github.com/sobolevn/git-secret.git git-secret + cd git-secret && make build + PREFIX="$HOME/gitsecret" make install + echo "$HOME/gitsecret" >> $GITHUB_PATH + echo "$HOME/gitsecret/bin" >> $GITHUB_PATH + - name: Decrypt secrets (non-fork only) + if: github.repository == 'oppia/oppia-android' + env: + GIT_SECRET_GPG_PRIVATE_KEY: ${{ secrets.GIT_SECRET_GPG_PRIVATE_KEY }} + run: | + cd $HOME + # NOTE TO DEVELOPERS: Make sure to never print this key directly to stdout! + echo $GIT_SECRET_GPG_PRIVATE_KEY | base64 --decode > ./git_secret_private_key.gpg + gpg --import ./git_secret_private_key.gpg + cd $GITHUB_WORKSPACE + git secret reveal + - name: Unzip Bazel binary + run: | + cd $HOME/oppia-bazel + unzip bazel-build.zip + cd $GITHUB_WORKSPACE + chmod a+x $HOME/oppia-bazel/bazel + - name: Run Oppia Test (with caching, non-fork only) + if: github.repository == 'oppia/oppia-android' + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools --remote_http_cache=$BAZEL_REMOTE_CACHE_URL --google_credentials=./config/oppia-dev-workflow-remote-cache-credentials.json -- ${{ matrix.test-target }} + - name: Run Oppia Test (without caching, fork only) + if: github.repository != 'oppia/oppia-android' + env: + BAZEL_REMOTE_CACHE_URL: ${{ secrets.BAZEL_REMOTE_CACHE_URL }} + run: $HOME/oppia-bazel/bazel test --override_repository=android_tools=$GITHUB_WORKSPACE/tmp/android_tools -- ${{ matrix.test-target }} + + # Reference: https://github.community/t/127354/7. + check_test_results: + name: Check Bazel Test Results + needs: bazel_run_test + if: ${{ always() }} + runs-on: ubuntu-18.04 + steps: + - name: Check tests passed + if: ${{ needs.bazel_run_test.result != 'success' }} + run: exit 1