From 7509eecc39a44b99b880bd3cb431011d38378c71 Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Sun, 30 Jun 2024 12:52:15 -0500 Subject: [PATCH 1/2] Initial clean up of actions --- .github/workflows/ci.yml | 12 --- .github/workflows/code-coverage.yml | 10 +- .github/workflows/codeql-analysis.yml | 3 +- .github/workflows/nightly-ci.yml | 8 +- .github/workflows/nightly-maven-ci.yml | 75 -------------- .../workflows/update-maven-repo.yml.disabled | 98 ------------------- 6 files changed, 4 insertions(+), 202 deletions(-) delete mode 100644 .github/workflows/nightly-maven-ci.yml delete mode 100644 .github/workflows/update-maven-repo.yml.disabled diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 040263091..f895c96d5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,18 +110,6 @@ jobs: fail_ci_if_error: false verbose: true - # If we have a buildScanUri comment on the PR - # - # NB: This only works if you're on the main MegaMek\megameklab repo - # for now due to a GitHub Actions limitation. - # CAW: temporarily halted https://github.com/thollander/actions-comment-pull-request/issues/17 - # - name: Comment on PR with Build Scan URI - # uses: thollander/actions-comment-pull-request@master - # if: always() && steps.gradle_build.outputs.buildScanUri != '' - # with: - # message: Build scan available at ${{ steps.gradle_build.outputs.buildScanUri }} - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Put the Windows Release in an artifact # NB: Due to a GitHub Actions limitation we won't know what the filename is in order to display it somewhere. - name: Upload Windows Release diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index f3526f882..9d19fbc9e 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -37,7 +37,7 @@ jobs: # See: https://github.com/MegaMek/megamek/wiki/Working-With-Gradle - name: Setup Composite Build for MegaMekLab run: | - echo "includeBuild '../megamek'" >./megameklab/settings_local.gradle + echo "includeBuild '../megamek'" >> ./megameklab/settings_local.gradle # Checkout the latest MegaMek source and put it in: ./megamek - name: Checkout MegaMek @@ -53,18 +53,12 @@ jobs: distribution: ${{ matrix.java-distribution }} java-version: ${{ matrix.java-version }} - # Make sure we can execute the Gradle wrapper - - name: Grant execute permission for gradlew (*nix or MacOS) - working-directory: megameklab - run: chmod +x gradlew - if: runner.os != 'Windows' - - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 - name: Build with Gradle working-directory: megameklab - run: ./gradlew build --stacktrace --scan + run: ./gradlew test # If the build step fails, try to upload any test logs in case it was a unit test failure. # diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 2feb3ff7b..468d7d57c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -14,7 +14,6 @@ on: push: branches: [master] pull_request: - # The branches below must be a subset of the branches above branches: [master] schedule: - cron: "24 16 * * 4" @@ -106,7 +105,7 @@ jobs: - name: Build with Gradle working-directory: megameklab - run: ./gradlew build --stacktrace --scan + run: ./gradlew jar - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml index ce5312431..ba949be94 100644 --- a/.github/workflows/nightly-ci.yml +++ b/.github/workflows/nightly-ci.yml @@ -38,7 +38,7 @@ jobs: # See: https://github.com/MegaMek/megamek/wiki/Working-With-Gradle - name: Setup Composite Build for MegaMekLab run: | - echo "includeBuild '../megamek'" >./megameklab/settings_local.gradle + echo "includeBuild '../megamek'" >> ./megameklab/settings_local.gradle # Checkout the latest MegaMek source and put it in: ./megamek - name: Checkout MegaMek @@ -54,12 +54,6 @@ jobs: distribution: ${{ matrix.java-distribution }} java-version: ${{ matrix.java-version }} - # Don't run this for Windows. - - name: Grant execute permission for gradlew (*nix or MacOS) - working-directory: megameklab - run: chmod +x gradlew - if: runner.os != 'Windows' - - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 diff --git a/.github/workflows/nightly-maven-ci.yml b/.github/workflows/nightly-maven-ci.yml deleted file mode 100644 index e6ca410cd..000000000 --- a/.github/workflows/nightly-maven-ci.yml +++ /dev/null @@ -1,75 +0,0 @@ -# Builds MegaMekLab for CI each Night using our Maven Repo. -# -# Jobs: -# - nightly_maven_ci: Build MegaMekLab for CI using our Maven Repos -name: MegaMekLab Nightly Maven CI - -on: - schedule: - # Nightly at Midnight (UTC) - # ref: https://crontab.guru/every-night - - cron: "0 0 * * *" - -# Setup the Build Scan "VCS" link for all gradle invocations -# -# Disable maven pooling to deal with Azure SNAT resets -# https://github.com/actions/virtual-environments/issues/1499#issuecomment-689467080 -env: - GRADLE_OPTS: "-Dscan.link.VCS=https://github.com/MegaMek/megameklab/commit/${{ github.sha }} -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120" - -jobs: - nightly_maven_ci: - runs-on: ${{ matrix.os }} - - # Run this job once for each combination in the matrix below. - strategy: - matrix: - os: [ubuntu-latest, windows-latest] - java-distribution: [temurin] - java-version: [17] - fail-fast: false - - name: Nightly MegaMekLab Maven CI ${{ matrix.os }} on ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }} - - steps: - # Checkout the latest source and put it in: ./megameklab - - uses: actions/checkout@v4 - with: - path: megameklab - - # Composite Build is NOT setup for this job. - - # Checkout the latest MegaMek source and put it in: ./megamek - - name: Checkout MegaMek - uses: actions/checkout@v4 - with: - repository: MegaMek/megamek - path: megamek - - # Setup the requested Java Distribution and Version from the matrix - - name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 - with: - distribution: ${{ matrix.java-distribution }} - java-version: ${{ matrix.java-version }} - - # Don't run this for Windows. - - name: Grant execute permission for gradlew (*nix or MacOS) - working-directory: megameklab - run: chmod +x gradlew - if: runner.os != 'Windows' - - # Include --stacktrace to make some build failures easier to figure out. - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Build with Gradle - working-directory: megameklab - run: ./gradlew clean build --continue --stacktrace --max-workers=1 --scan - - - name: Upload Test Logs on Failure - uses: actions/upload-artifact@v4 - if: failure() - with: - name: ${{ matrix.os }}-${{ matrix.java-distribution }}-jdk${{ matrix.java-version }}-maven-ci-failure-logs - path: megameklab/megameklab/build/reports/ diff --git a/.github/workflows/update-maven-repo.yml.disabled b/.github/workflows/update-maven-repo.yml.disabled deleted file mode 100644 index 4a66df437..000000000 --- a/.github/workflows/update-maven-repo.yml.disabled +++ /dev/null @@ -1,98 +0,0 @@ -# This workflow updates the MML Maven Repo on push to master -name: Update Maven Repo - -on: - push: - branches: [master] - paths: - - "megameklab/src/**" - - "megameklab/resources/**" - -jobs: - update_maven_repo: - runs-on: ${{ matrix.os }} - - # Run this job once for each combination in the matrix below. - strategy: - matrix: - os: [ubuntu-latest] # For Maven Repository Update running on *nix is sufficient - java-distribution: [temurin] - java-version: [17] - - steps: - # Put the MML repo in a subfolder to make updating the Maven repo easier - - uses: actions/checkout@v4 - with: - path: megameklab - - # Grab the MM repo too - - uses: actions/checkout@v4 - with: - repository: MegaMek/megamek - path: megamek - - # Setup composite build for MML - # see: https://github.com/MegaMek/megamek/wiki/Working-With-Gradle - - name: Setup Composite Build for MML - working-directory: megameklab - run: | - echo "includeBuild '../megamek'" >settings_local.gradle - - # Setup the requested Java Distribution and Version from the matrix - - name: Set up ${{ matrix.java-distribution }} JDK ${{ matrix.java-version }} - uses: actions/setup-java@v4 - with: - distribution: ${{ matrix.java-distribution }} - java-version: ${{ matrix.java-version }} - - # Make sure we can execute the Gradle wrapper - - name: Grant execute permission for gradlew (*nix or MacOS) - working-directory: megameklab - run: chmod +x gradlew - if: runner.os != 'Windows' - - # Create the actual maven repo bits with Gradle - - name: Publish Maven Repo with Gradle - working-directory: megameklab - run: ./gradlew publishPublishMMLibraryPublicationToMavenRepository - - # Get the current Maven repo contents - - name: Checkout Maven Repo - if: github.repository == 'MegaMek/megameklab' - uses: actions/checkout@v4 - with: - repository: MegaMek/mavenrepo - path: mavenrepo - - # Create an update - - name: Copy Maven Outputs to Repo - if: github.repository == 'MegaMek/megameklab' - working-directory: megameklab/megameklab/build/mavenrepo/ - run: | - cp -r . ../../../../mavenrepo/ - - # In case we run into an issue, use git status to help us understand what happened. - - name: Inspect git status output - if: github.repository == 'MegaMek/megameklab' - working-directory: mavenrepo - run: | - git status - - # Add the changes under the username and email of the user who pushed the code - - name: Commit changes to the Maven Repo - if: github.repository == 'MegaMek/megameklab' - working-directory: mavenrepo - run: | - git add . - git config user.email ${{ github.event.pusher.email }} - git config user.name ${{ github.event.pusher.name }} - git commit -m "MegaMek ${{ github.event.after }}" -m "${{ github.event.compare }}" - - # Use an SSH deploy key (with write privs) to update the maven repo - - name: Setup SSH and Push changes to the Maven Repo - if: github.repository == 'MegaMek/megameklab' - working-directory: mavenrepo - run: | - eval "$(ssh-agent -s)" - ssh-add - <<< "${{ secrets.MAVEN_REPO_DEPLOY_KEY }}" - git push "git@github.com:MegaMek/mavenrepo.git" HEAD:master From d652553ddc84f46a9a2db28635e74cee7bd80c9e Mon Sep 17 00:00:00 2001 From: Richard J Hancock Date: Sun, 30 Jun 2024 16:23:45 -0500 Subject: [PATCH 2/2] Fix for failing to build. --- .../dialog/MegaMekLabUnitSelectorDialog.java | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/megameklab/src/megameklab/ui/dialog/MegaMekLabUnitSelectorDialog.java b/megameklab/src/megameklab/ui/dialog/MegaMekLabUnitSelectorDialog.java index e49d1c649..f6aacae5d 100644 --- a/megameklab/src/megameklab/ui/dialog/MegaMekLabUnitSelectorDialog.java +++ b/megameklab/src/megameklab/ui/dialog/MegaMekLabUnitSelectorDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 - The MegaMek Team. All rights reserved. + * Copyright (c) 2024 - The MegaMek Team. All rights reserved. * * This file is part of MegaMekLab. * @@ -18,6 +18,23 @@ */ package megameklab.ui.dialog; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.util.function.Consumer; + +import javax.swing.AbstractAction; +import javax.swing.Action; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JRootPane; +import javax.swing.KeyStroke; + import megamek.client.ui.Messages; import megamek.client.ui.swing.UnitLoadingDialog; import megamek.client.ui.swing.dialog.AbstractUnitSelectorDialog; @@ -25,27 +42,21 @@ import megamek.client.ui.swing.tileset.MMStaticDirectoryManager; import megamek.client.ui.swing.util.PlayerColour; import megamek.common.Entity; -import megamek.common.MechSummary; import megamek.common.TechConstants; import megamek.common.icons.Camouflage; import megameklab.util.CConfig; -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.KeyEvent; -import java.util.function.Consumer; - public class MegaMekLabUnitSelectorDialog extends AbstractUnitSelectorDialog { - //region Variable Declarations + // region Variable Declarations private Entity chosenEntity; private final boolean allowPickWithoutClose; private Consumer entityPickCallback; - //endregion Variable Declarations + // endregion Variable Declarations /** - * Constructs a Unit Selector Dialog that only allows choosing with closing the dialog. + * Constructs a Unit Selector Dialog that only allows choosing with closing the + * dialog. */ public MegaMekLabUnitSelectorDialog(JFrame parent, UnitLoadingDialog unitLoadingDialog) { super(parent, unitLoadingDialog); @@ -61,11 +72,12 @@ public MegaMekLabUnitSelectorDialog(JFrame parent, UnitLoadingDialog unitLoading } /** - * Constructs a Unit Selector Dialog that allows choosing a Unit while keeping the - * dialog open by pressing Enter or the "Select" button. The entityPickCallback - * method will be called when a Unit is selected in this way. + * Constructs a Unit Selector Dialog that allows choosing a Unit while keeping + * the dialog open by pressing Enter or the "Select" button. The + * entityPickCallback method will be called when a Unit is selected in this way. */ - public MegaMekLabUnitSelectorDialog(JFrame parent, UnitLoadingDialog unitLoadingDialog, Consumer entityPickCallback) { + public MegaMekLabUnitSelectorDialog(JFrame parent, UnitLoadingDialog unitLoadingDialog, + Consumer entityPickCallback) { super(parent, unitLoadingDialog); gameTechLevel = TechConstants.T_SIMPLE_UNOFFICIAL; allowPickWithoutClose = true; @@ -75,9 +87,9 @@ public MegaMekLabUnitSelectorDialog(JFrame parent, UnitLoadingDialog unitLoading } this.entityPickCallback = entityPickCallback; initialize(); - // This overrides the default close behavior to avoid selecting another unit when closing with ESC or - // the Close button. AbstractUnitSelectorDialog should probably be changed to make the - // selectedEntity null in these cases + // This overrides the default close behavior to avoid selecting another unit + // when closing with ESC or the Close button. AbstractUnitSelectorDialog should + // probably be changed to make the selectedEntity null in these cases JRootPane rootPane = getRootPane(); KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escape, CLOSE_ACTION); @@ -88,7 +100,7 @@ public MegaMekLabUnitSelectorDialog(JFrame parent, UnitLoadingDialog unitLoading setVisible(true); } - // Only necessary to override the default close behavior, see contructor + // Only necessary to override the default close behavior, see constructor Action closeAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { @@ -98,10 +110,10 @@ public void actionPerformed(ActionEvent e) { @Override public void updateOptionValues() { - + // Why is this empty? } - //region Button Methods + // region Button Methods @Override protected JPanel createButtonsPanel() { JPanel panelButtons = new JPanel(new GridBagLayout()); @@ -117,7 +129,7 @@ protected JPanel createButtonsPanel() { panelButtons.add(buttonSelectClose, new GridBagConstraints()); buttonClose = new JButton(Messages.getString("Close")); - // Override the default close behavior, see contructor + // Override the default close behavior, see constructor buttonClose.addActionListener(e -> closeWithoutSelection()); panelButtons.add(buttonClose, new GridBagConstraints()); @@ -143,7 +155,7 @@ protected void select(boolean close) { entityPickCallback.accept(chosenEntity); } } - //endregion Button Methods + // endregion Button Methods /** * @return the chosenEntity @@ -157,7 +169,7 @@ protected Entity refreshUnitView() { Entity selectedEntity = super.refreshUnitView(); if (selectedEntity != null) { Image base = MMStaticDirectoryManager.getMechTileset().imageFor(selectedEntity); - EntityImage entityImage = EntityImage.createIcon(base, Camouflage.of(PlayerColour.GOLD), labelImage, selectedEntity); + EntityImage entityImage = EntityImage.createIcon(base, Camouflage.of(PlayerColour.GOLD), selectedEntity); entityImage.loadFacings(); labelImage.setIcon(new ImageIcon(entityImage.getFacing(0))); }