Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Improve PR builder workflow #6786

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
28 changes: 16 additions & 12 deletions .github/workflows/pr-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ env:
jobs:
lint:
name: ⬣ ESLint (STATIC ANALYSIS)
if: ${{ github.event_name == 'pull_request' || github.event.label.name == 'trigger-pr-builder' }}
# if: ${{ github.event_name == 'pull_request' || github.event.label.name == 'trigger-pr-builder' }}
if: ${{ false }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -84,7 +85,8 @@ jobs:

typecheck:
name: ʦ Typecheck (STATIC ANALYSIS)
if: ${{ github.event.label.name == 'trigger-pr-builder' || github.event_name == 'pull_request'}}
# if: ${{ github.event.label.name == 'trigger-pr-builder' || github.event_name == 'pull_request'}}
if: ${{ false }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -142,6 +144,7 @@ jobs:

test:
name: 👾 Unit Test (TESTING)
if: ${{ false }}
needs: [ typecheck ]
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -227,7 +230,6 @@ jobs:

build:
name: 🚧 Build
needs: [ test, typecheck ]
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -237,15 +239,23 @@ jobs:
pnpm-version: [ 8.7.4 ]
steps:
- name: ⬇️ Checkout
id: checkout
uses: actions/checkout@v2.3.3
id: checkout-master
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🟢 Setup node
id: setup-node
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}

- name: 🐳 Set SHAs for Nx
id: set-shas
uses: nrwl/nx-set-shas@v3
with:
main-branch-name: "master"

- name: ☕ Set up JDK 11
id: jdk-setup
uses: actions/setup-java@v3
Expand Down Expand Up @@ -286,13 +296,7 @@ jobs:

- name: 👷 PNPM Build
id: build-with-pnpm
run: pnpm build

- name: 🏗️ Maven Build identity-apps-core
id: build-with-maven
run: |
cd identity-apps-core
mvn clean install -U -Dlint.exec.skip=true -Dbootstrap.exec.skip=true
run: pnpm nx affected --base=origin/master --head=${{ env.NX_HEAD }} --target=build --parallel=3

- name: 💾 Cache local Maven repository
id: cache-maven-m2
Expand Down
11 changes: 6 additions & 5 deletions identity-apps-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"author": "WSO2",
"license": "Apache-2.0",
"scripts": {
"build": "pnpm nx run theme:build && node theme-distribute.js",
"clean": "pnpm clean:lock-files && pnpm clean:maven-folders && pnpm clean:node-modules",
"clean:lock-files": "pnpm rimraf package-lock.json && pnpm rimraf pnpm-lock.yaml && pnpm rimraf yarn.lock",
"clean:maven-folders": "pnpm rimraf target",
"clean:node-modules": "pnpm rimraf node_modules"
"build": "mvn clean install",
"build:theme": "pnpm nx run theme:build && node theme-distribute.js",
"clean": "pnpm clean:theme-folders && pnpm clean:node-modules && pnpm clean:maven-folders",
"clean:maven-folders": "mvn clean",
"clean:node-modules": "pnpm rimraf node_modules",
"clean:theme-folders": "node theme-distribute.js clean"
},
"dependencies": {
"@wso2is/theme": "^2.1.4",
Expand Down
20 changes: 3 additions & 17 deletions identity-apps-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@

<build>
<plugins>
<!-- Build all npm packages (apps & modules) -->
<!-- Intall dependencies and Build theme module -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<version>1.6.0</version>
Expand All @@ -603,21 +603,7 @@
<workingDirectory>${basedir}</workingDirectory>
</configuration>
</execution>
<execution>
<id>run-linter</id>
<goals>
<goal>exec</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<executable>pnpm</executable>
<arguments>
<argument>lint</argument>
</arguments>
<skip>${lint.exec.skip}</skip>
<workingDirectory>${basedir}</workingDirectory>
</configuration>
</execution>

<execution>
<id>npm run build (compile)</id>
<goals>
Expand All @@ -627,7 +613,7 @@
<configuration>
<executable>pnpm</executable>
<arguments>
<argument>build</argument>
<argument>build:theme</argument>
</arguments>
<workingDirectory>${basedir}</workingDirectory>
</configuration>
Expand Down
12 changes: 11 additions & 1 deletion identity-apps-core/theme-distribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* specific language governing permissions and limitations
* under the License.
*/
/* eslint-disable no-console */

const path = require("path");
const fs = require("fs-extra");
Expand All @@ -25,6 +26,7 @@ const apps = [ "authentication-portal", "recovery-portal", "x509-certificate-aut
async function deleteExistingThemesFolder() {
for (const app of apps) {
const themePath = path.join(__dirname, "apps", app, "src", "main", "webapp", "libs", "themes");

if (fs.existsSync(themePath)) {
console.log(`Deleting existing themes folder in ${app} app...`);
await fs.remove(themePath);
Expand All @@ -50,4 +52,12 @@ async function main() {
}
}

main();
// Parse command-line arguments.
const args = process.argv.slice(2);

// Check which function to run based on the arguments.
if (args.includes("clean")) {
deleteExistingThemesFolder().catch(console.error);
} else {
main().catch(console.error);
}
Loading