From 6a9db3d5849cea2f6f7d77a5db02f5402eee01de Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:11:14 -0600 Subject: [PATCH 01/18] ci: Add initial action configuration and tests Signed-off-by: Roger Barker --- .github/workflows/test.yml | 278 +++++++--- .gitignore | 1029 ++++++++++++++++++++++++++++++++++++ README.md | 180 +------ action.yml | 244 +++++++-- 4 files changed, 1431 insertions(+), 300 deletions(-) create mode 100644 .gitignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1c6f27c..bad34a7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,123 +2,251 @@ name: Test Action on: push: - branches: [ main, develop ] + branches: + - main pull_request: - branches: [ main ] - workflow_dispatch: - + types: + - converted_to_draft + - ready_for_review + - synchronize + - opened + - reopened permissions: contents: read +defaults: + run: + shell: bash + jobs: - test-basic-checkout: - name: Test Basic Checkout + test-all: + name: Test Action on ${{ matrix.os }} with ${{ matrix.language }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + steps: + - name: Checkout Repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Run Action + uses: ./ + id: test-all + with: + checkout: true + checkout-fetch-depth: 0 + checkout-ref: main + setup-java: true + java-distribution: 'temurin' + java-version: '17' + setup-gradle: true + gradle-version: '7.5' + setup-node: true + node-version: '18' + setup-python: true + python-version: '3.9' + setup-go: true + go-version: '1.20' + setup-rust: true + rust-version: '1.70.0' + setup-swift: true + swift-version: '5.7' + + - name: Verify Setup + run: | + echo "::group::Verify Checkout Outputs" + echo "Checkout Ref: ${{ steps.test-all.outputs.checkout-ref }}" + echo "Checkout Commit: ${{ steps.test-all.outputs.checkout-commit }}" + echo "::group::Verify Java Outputs" + echo "Java Distribution: ${{ steps.test-all.outputs.java-distribution }}" + echo "Java Version: ${{ steps.test-all.outputs.java-version }}" + echo "Java Path: ${{ steps.test-all.outputs.java-path }}" + echo "Java Cache Hit: ${{ steps.test-all.outputs.java-cache-hit }}" + java -version + echo "::endgroup::" + echo "::group::Verify Gradle Outputs" + echo "Gradle Version: ${{ steps.test-all.outputs.gradle-version }}" + echo "Gradle Build Scan URL: ${{ steps.test-all.outputs.gradle-build-scan-url }}" + echo "Gradle Dependency Graph File: ${{ steps.test-all.outputs.gradle-dependency-graph-file }}" + gradle -v + echo "::endgroup::" + echo "::group::Verify Node.js Outputs" + echo "Node.js Version: ${{ steps.test-all.outputs.node-version }}" + echo "Node.js Cache Hit: ${{ steps.test-all.outputs.node-cache-hit }}" + node -v + npm -v + echo "::endgroup::" + echo "::group::Verify Python Outputs" + echo "Python Version: ${{ steps.test-all.outputs.python-version }}" + echo "Python Path: ${{ steps.test-all.outputs.python-path }}" + echo "Python Cache Hit: ${{ steps.test-all.outputs.python-cache-hit }}" + python --version + pip --version + echo "::endgroup::" + echo "::group::Verify Go Outputs" + echo "Go Version: ${{ steps.test-all.outputs.go-version }}" + echo "Go Cache Hit: ${{ steps.test-all.outputs.go-cache-hit }}" + go version + echo "::endgroup::" + echo "::group::Verify Rust Outputs" + echo "Rust Name: ${{ steps.test-all.outputs.rust-name }}" + echo "Rust Cache Key: ${{ steps.test-all.outputs.rust-cachekey }}" + rustc --version + cargo --version + echo "::endgroup::" + echo "::group::Verify Swift Outputs" + echo "Swift Version: ${{ steps.test-all.outputs.swift-version }}" + echo "Swift Toolchain: ${{ steps.test-all.outputs.swift-toolchain }}" + echo "Swift SDKs: ${{ steps.test-all.outputs.swift-sdks }}" + swift --version + echo "::endgroup::" + + test-checkout: + name: Test Checkout Action + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Run Checkout Action + uses: ./ + id: test-checkout + with: + checkout: true + checkout-fetch-depth: 0 + checkout-ref: main + + - name: Verify Checkout Outputs + run: | + echo "Checkout Ref: ${{ steps.test-checkout.outputs.checkout-ref }}" + echo "Checkout Commit: ${{ steps.test-checkout.outputs.checkout-commit }}" + git_value=$(git log -1 --oneline) + echo "Git Commit: ${git_value}" + + test-setup-java: + name: Test Setup Java Action runs-on: ubuntu-latest steps: - - name: Initialize job + - name: Run Setup Java Action uses: ./ - - - name: Verify checkout + id: test-setup-java + with: + setup-java: true + java-distribution: 'temurin' + java-version: '17' + + - name: Verify Java Outputs run: | - echo "Current directory: $(pwd)" - echo "Files in repo:" - ls -la + echo "Java Distribution: ${{ steps.test-setup-java.outputs.java-distribution }}" + echo "Java Version: ${{ steps.test-setup-java.outputs.java-version }}" + echo "Java Path: ${{ steps.test-setup-java.outputs.java-path }}" + echo "Java Cache Hit: ${{ steps.test-setup-java.outputs.java-cache-hit }}" + java -version - test-node: - name: Test Node.js Setup + test-setup-gradle: + name: Test Setup Gradle Action runs-on: ubuntu-latest steps: - - name: Initialize job with Node.js + - name: Run Setup Gradle Action uses: ./ + id: test-setup-gradle with: - setup-node: 'true' - node-version: '20' - node-cache: 'npm' - - - name: Verify Node.js + setup-gradle: true + gradle-version: '7.5' + + - name: Verify Gradle Outputs run: | - node --version - npm --version + echo "Gradle Version: ${{ steps.test-setup-gradle.outputs.gradle-version }}" + echo "Gradle Build Scan URL: ${{ steps.test-setup-gradle.outputs.gradle-build-scan-url }}" + echo "Gradle Dependency Graph File: ${{ steps.test-setup-gradle.outputs.gradle-dependency-graph-file }}" + gradle -v - test-python: - name: Test Python Setup + test-setup-node: + name: Test Setup Node.js Action runs-on: ubuntu-latest steps: - - name: Initialize job with Python + - name: Run Setup Node.js Action uses: ./ + id: test-setup-node with: - setup-python: 'true' - python-version: '3.11' - - - name: Verify Python + setup-node: true + node-version: '18' + + - name: Verify Node.js Outputs run: | - python --version - pip --version + echo "Node.js Version: ${{ steps.test-setup-node.outputs.node-version }}" + echo "Node.js Cache Hit: ${{ steps.test-setup-node.outputs.node-cache-hit }}" + node -v + npm -v - test-java: - name: Test Java Setup + test-setup-python: + name: Test Setup Python Action runs-on: ubuntu-latest steps: - - name: Initialize job with Java + - name: Run Setup Python Action uses: ./ + id: test-setup-python with: - setup-java: 'true' - java-version: '17' - java-distribution: 'temurin' - - - name: Verify Java + setup-python: true + python-version: '3.13' + + - name: Verify Python Outputs run: | - java -version - javac -version + echo "Python Version: ${{ steps.test-setup-python.outputs.python-version }}" + echo "Python Path: ${{ steps.test-setup-python.outputs.python-path }}" + echo "Python Cache Hit: ${{ steps.test-setup-python.outputs.python-cache-hit }}" + python --version + pip --version - test-go: - name: Test Go Setup + test-setup-go: + name: Test Setup Go Action runs-on: ubuntu-latest steps: - - name: Initialize job with Go + - name: Run Setup Go Action uses: ./ + id: test-setup-go with: - setup-go: 'true' - go-version: '1.21' - - - name: Verify Go + setup-go: true + go-version: '1.20' + + - name: Verify Go Outputs run: | + echo "Go Version: ${{ steps.test-setup-go.outputs.go-version }}" + echo "Go Cache Hit: ${{ steps.test-setup-go.outputs.go-cache-hit }}" go version - test-multi-language: - name: Test Multi-Language Setup + test-setup-rust: + name: Test Setup Rust Action runs-on: ubuntu-latest steps: - - name: Initialize job with multiple languages + - name: Run Setup Rust Action uses: ./ + id: test-setup-rust with: - setup-node: 'true' - node-version: '20' - setup-python: 'true' - python-version: '3.11' - - - name: Verify all languages + setup-rust: true + rust-version: '1.70.0' + + - name: Verify Rust Outputs run: | - echo "Node version: $(node --version)" - echo "npm version: $(npm --version)" - echo "Python version: $(python --version)" - echo "pip version: $(pip --version)" + echo "Rust Name: ${{ steps.test-setup-rust.outputs.rust-name }}" + echo "Rust Cache Key: ${{ steps.test-setup-rust.outputs.rust-cachekey }}" + rustc --version + cargo --version - test-no-checkout: - name: Test Without Checkout - runs-on: ubuntu-latest + test-setup-swift: + name: Test Setup Swift Action + runs-on: macos-latest steps: - - name: Manual checkout - uses: actions/checkout@v4 - - - name: Initialize job without checkout + - name: Run Setup Swift Action uses: ./ + id: test-setup-swift with: - checkout: 'false' - setup-node: 'true' - node-version: '20' - - - name: Verify setup + setup-swift: true + swift-version: '5.7' + + - name: Verify Swift Outputs run: | - node --version - ls -la + echo "Swift Version: ${{ steps.test-setup-swift.outputs.swift-version }}" + echo "Swift Toolchain: ${{ steps.test-setup-swift.outputs.swift-toolchain }}" + echo "Swift SDKs: ${{ steps.test-setup-swift.outputs.swift-sdks }}" + swift --version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c184c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,1029 @@ +######################################################################################################################## +## Autogenerated Definitions - DO NOT EDIT THIS SECTION. Instead, edit the section below named "Custom Definitions". ## +######################################################################################################################## + +### Maven template +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath + +### MonoDevelop template +#User Specific +*.userprefs +*.usertasks + +#Mono Project Files +*.pidb +*.resources +test-results/ + +### NotepadPP template +# Notepad++ backups # +*.bak + +### VisualStudioCode template +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### Kate template +# Swap Files # +.*.kate-swp +.swp.* + +### Diff template +*.patch +*.diff + +### Eclipse template +.metadata +bin/ +tmp/ +*.tmp +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet + +# Uncomment this line if you wish to ignore the project description file. +# Typically, this file would be tracked if it contains build/dependency configurations: +#.project + +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Backup template +*.gho +*.ori +*.orig + +### PuTTY template +# Private key +*.ppk + +### Windows template +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +### SublimeText template +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + +### MicrosoftOffice template + +# Word temporary +~$*.doc* + +# Word Auto Backup File +Backup of *.doc* + +# Excel temporary +~$*.xls* + +# Excel Backup File +*.xlk + +# PowerPoint temporary +~$*.ppt* + +# Visio autosave temporary files +*.~vsd* + +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +.idea/artifacts +.idea/compiler.xml +.idea/jarRepositories.xml +.idea/modules.xml +.idea/*.iml +.idea/modules +*.iml +*.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +### LibreOffice template +# LibreOffice locks +.~lock.*# + +### Archives template +# It's better to unpack these files and commit the raw source because +# git has its own built in compression methods. +*.7z +*.jar +*.rar +*.zip +*.gz +*.gzip +*.bzip +*.bzip2 +*.bz2 +*.xz +*.lzma +*.xar + +# Packing-only formats +*.iso +*.tar + +# Package management formats +*.dmg +*.xpi +*.gem +*.egg +*.deb +*.rpm +*.txz + +### Dropbox template +# Dropbox settings and caches +.dropbox +.dropbox.attr +.dropbox.cache + +### macOS template +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Java template +# Compiled class file +*.class + +# Log file + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.war +*.nar +*.ear +*.tar.gz + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +### Kotlin template +# Compiled class file + +# Log file + +# BlueJ files + +# Mobile Tools for Java (J2ME) + +# Package Files # + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml + +### OpenSSL template +# OpenSSL-related files best not committed + +## Certificate Authority +*.ca + +## Certificate +*.crt + +## Certificate Sign Request +*.csr + +## Certificate +*.der + +## Key database file +*.kdb + +## OSCP request data +*.org + +## PKCS #12 +*.p12 + +## PEM-encoded certificate data +*.pem + +## Random number seed +*.rnd + +## SSLeay data +*.ssleay + +## S/MIME message +*.smime + +### NetBeans template +**/nbproject/private/ +**/nbproject/Makefile-*.mk +**/nbproject/Package-*.bash +build/ +nbbuild/ +dist/ +nbdist/ +.nb-gradle/ + +### Linux template +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### TextMate template +*.tmproj +*.tmproject +tmtags + +### VisualStudio template +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp_proj +*_wpftmp.csproj +*.tlog +*.vspscc +*.vssscc +.builds +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +*.code-workspace + +# Local History for Visual Studio Code + +# Windows Installer files from build outputs + +# JetBrains Rider +*.sln.iml + +### Gradle template +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core +# JDT-specific (Eclipse Java Development Tools) + +### Vim template +# Swap +[._]*.s[a-v][a-z] +!*.svg # comment out if you don't need vector files +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim +Sessionx.vim + +# Temporary +.netrwhist + +# Persistent undo +[._]*.un~ + +### Patch template +*.rej + +### GPG template +secring.* + +######################################################################################################################## +## Custom Definitions ## +######################################################################################################################## + +### Ignore all Jetbrains IDE files +.idea/ + +### CI Pipeline Created Files +gha-creds-*.json + +### Snyk Files +.dccache +snyk-code.html +snyk-code.json +snyk/ diff --git a/README.md b/README.md index 1116724..99faddd 100644 --- a/README.md +++ b/README.md @@ -1,179 +1,3 @@ -# initialize-github-job +# Initialize Github Job -Common steps for initializing a job for GitHub actions. This composite action provides a flexible way to set up your GitHub Actions workflow with repository checkout and various programming language runtimes. - -## Features - -- 🔄 Repository checkout with customizable options -- 🟢 Node.js setup with version management and caching -- 🐍 Python setup with version management and caching -- ☕ Java setup with multiple distributions -- 🔵 Go setup with module caching -- ⚡ Optimized with dependency caching support - -## Usage - -### Basic Example - Checkout Only - -```yaml -- name: Initialize job - uses: PandasWhoCode/initialize-github-job@v1 -``` - -### Node.js Project - -```yaml -- name: Initialize Node.js job - uses: PandasWhoCode/initialize-github-job@v1 - with: - setup-node: 'true' - node-version: '20' - node-cache: 'npm' -``` - -### Python Project - -```yaml -- name: Initialize Python job - uses: PandasWhoCode/initialize-github-job@v1 - with: - setup-python: 'true' - python-version: '3.11' - python-cache: 'pip' -``` - -### Java Project - -```yaml -- name: Initialize Java job - uses: PandasWhoCode/initialize-github-job@v1 - with: - setup-java: 'true' - java-version: '17' - java-distribution: 'temurin' -``` - -### Go Project - -```yaml -- name: Initialize Go job - uses: PandasWhoCode/initialize-github-job@v1 - with: - setup-go: 'true' - go-version: '1.21' -``` - -### Multi-Language Project - -```yaml -- name: Initialize multi-language job - uses: PandasWhoCode/initialize-github-job@v1 - with: - setup-node: 'true' - node-version: '20' - node-cache: 'npm' - setup-python: 'true' - python-version: '3.11' - python-cache: 'pip' -``` - -### Skip Checkout - -```yaml -- name: Initialize without checkout - uses: PandasWhoCode/initialize-github-job@v1 - with: - checkout: 'false' - setup-node: 'true' - node-version: '20' -``` - -### Custom Checkout Options - -```yaml -- name: Initialize with custom checkout - uses: PandasWhoCode/initialize-github-job@v1 - with: - checkout-ref: 'develop' - checkout-token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} - setup-node: 'true' -``` - -## Inputs - -### Checkout Options - -| Input | Description | Required | Default | -|-------|-------------|----------|---------| -| `checkout` | Whether to checkout the repository | No | `true` | -| `checkout-ref` | The branch, tag or SHA to checkout | No | `''` | -| `checkout-token` | Personal access token (PAT) used to fetch the repository | No | `${{ github.token }}` | - -### Node.js Options - -| Input | Description | Required | Default | -|-------|-------------|----------|---------| -| `setup-node` | Whether to setup Node.js | No | `false` | -| `node-version` | Node.js version to use | No | `20` | -| `node-version-file` | File containing the Node.js version (e.g., `.nvmrc`, `.node-version`) | No | `''` | -| `node-cache` | Package manager for caching (`npm`, `yarn`, `pnpm`) | No | `''` | - -### Python Options - -| Input | Description | Required | Default | -|-------|-------------|----------|---------| -| `setup-python` | Whether to setup Python | No | `false` | -| `python-version` | Python version to use | No | `3.x` | -| `python-cache` | Package manager for caching (`pip`, `pipenv`, `poetry`) | No | `''` | - -### Java Options - -| Input | Description | Required | Default | -|-------|-------------|----------|---------| -| `setup-java` | Whether to setup Java | No | `false` | -| `java-version` | Java version to use | No | `17` | -| `java-distribution` | Java distribution (`temurin`, `zulu`, `adopt`, etc.) | No | `temurin` | - -### Go Options - -| Input | Description | Required | Default | -|-------|-------------|----------|---------| -| `setup-go` | Whether to setup Go | No | `false` | -| `go-version` | Go version to use | No | `stable` | -| `go-cache` | Whether to cache Go modules | No | `true` | - -## Complete Workflow Example - -```yaml -name: CI - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Initialize job - uses: PandasWhoCode/initialize-github-job@v1 - with: - setup-node: 'true' - node-version: '20' - node-cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Run tests - run: npm test - - - name: Build - run: npm run build -``` - -## License - -This project is licensed under the terms specified in the LICENSE file. +TBD diff --git a/action.yml b/action.yml index 0fee385..bb8b290 100644 --- a/action.yml +++ b/action.yml @@ -6,107 +6,257 @@ inputs: checkout: description: 'Whether to checkout the repository' required: false - default: 'true' checkout-ref: description: 'The branch, tag or SHA to checkout' required: false - default: '' checkout-token: description: 'Personal access token (PAT) used to fetch the repository' required: false - default: ${{ github.token }} + checkout-fetch-depth: + description: 'Depth of commit history to fetch' + required: false setup-node: description: 'Whether to setup Node.js' required: false - default: 'false' node-version: description: 'Node.js version to use' required: false - default: '20' - node-version-file: - description: 'File containing the Node.js version (e.g., .nvmrc, .node-version)' - required: false - default: '' node-cache: description: 'Used to specify a package manager for caching (npm, yarn, pnpm)' required: false - default: '' - setup-python: - description: 'Whether to setup Python' - required: false - default: 'false' - python-version: - description: 'Python version to use' - required: false - default: '3.x' - python-cache: - description: 'Used to specify a package manager for caching (pip, pipenv, poetry)' + node-check-latest: + description: 'Whether to check for the latest Node.js version' required: false - default: '' setup-java: description: 'Whether to setup Java' required: false - default: 'false' java-version: description: 'Java version to use' required: false - default: '17' java-distribution: description: 'Java distribution (temurin, zulu, adopt, etc.)' required: false - default: 'temurin' + java-cache: + description: 'Whether to cache Java dependencies' + required: false + setup-gradle: + description: 'Whether to setup Gradle' + required: false + gradle-version: + description: 'Gradle version to use. If specified, this Gradle version will be downloaded, added to the PATH and used for invoking Gradle.' + required: false + default: 'wrapper' + gradle-cache-disabled: + description: 'Whether to disable Gradle caching' + required: false + default: 'false' + gradle-cache-read-only: + description: 'Whether to use read-only caching for Gradle' + required: false + cache-write-only: + description: 'When true, entries will not be restored from the cache but will be saved at the end of the Job.' + required: false + default: 'false' + setup-python: + description: 'Whether to setup Python' + required: false + python-version: + description: 'Python version to use' + required: false + python-cache: + description: 'Used to specify a package manager for caching (pip, pipenv, poetry)' + required: false + default: 'false' setup-go: description: 'Whether to setup Go' required: false - default: 'false' + default: 'true' go-version: description: 'Go version to use' required: false - default: 'stable' go-cache: description: 'Whether to cache Go modules' required: false + go-architecture: + description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' + required: false + setup-rust: + description: 'Whether to setup Rust' + required: false + rust-version: + description: 'Rust version to use' + required: false + rust-targets: + description: 'Comma-separated list of target triples to install for this toolchain' + required: false + rust-components: + description: 'Comma-separated list of components to be additionally installed' + required: false + setup-swift: + description: 'Whether to setup Swift' + required: false + swift-version: + description: 'Swift version to use' + required: false + swift-cache: + description: 'Whether to cache downloaded toolchain snapshots. Enabled by default, can be disabled in case of storage constraints.' + required: false default: 'true' + swift-prefer-oss-toolchain: + description: 'Whether to prefer installing Swift open source toolchain over using Xcode integrated toolchain.' + required: false + default: 'false' + swift-sdks: + description: 'Semi-colon separated list of Swift SDKs to install along with the main toolchain.' + required: false + +# expose outputs from the sub-actions +outputs: + checkout-ref: + description: 'The branch, tag or SHA that was checked out' + value: ${{ steps.checkout-code.outputs.ref }} + checkout-commit: + description: 'The commit SHA that was checked out' + value: ${{ steps.checkout-code.outputs.commit }} + java-distribution: + description: 'Distribution of Java that has been installed' + value: ${{ steps.setup-java.outputs.distribution }} + java-version: + description: 'Actual version of the java environment that has been installed' + value: ${{ steps.setup-java.outputs.version }} + java-path: + description: 'Path to where the java environment has been installed (same as $JAVA_HOME)' + value: ${{ steps.setup-java.outputs.path }} + java-cache-hit: + description: 'A boolean value to indicate an exact match was found for the primary key' + value: ${{ steps.setup-java.outputs.cache-hit }} + gradle-build-scan-url: + description: 'Link to the Build Scan® generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `setup-gradle` Step itself.' + value: ${{ steps.setup-gradle.outputs.build-scan-url }} + gradle-dependency-graph-file: + description: 'Path to the GitHub Dependency Graph snapshot file generated by a Gradle build. Note that this output applies to a Step executing Gradle, not to the `setup-gradle` Step itself.' + value: ${{ steps.setup-gradle.outputs.dependency-graph-file }} + gradle-version: + description: 'Version of Gradle that was setup by the action' + value: ${{ steps.setup-gradle.outputs.gradle-version }} + node-cache-hit: + description: 'A boolean value to indicate if a cache was hit.' + value: ${{ steps.setup-node.outputs.cache-hit }} + node-version: + description: 'The installed node version.' + value: ${{ steps.setup-node.outputs.node-version }} + python-version: + description: "The installed Python or PyPy version. Useful when given a version range as input." + value: ${{ steps.setup-python.outputs.python-version }} + python-cache-hit: + description: "A boolean value to indicate a cache entry was found" + value: ${{ steps.setup-python.outputs.cache-hit }} + python-path: + description: "The absolute path to the Python or PyPy executable." + value: ${{ steps.setup-python.outputs.python-path }} + go-version: + description: 'The installed Go version. Useful when given a version range as input.' + value: ${{ steps.setup-go.outputs.go-version }} + go-cache-hit: + description: 'A boolean value to indicate if a cache was hit' + value: ${{ steps.setup-go.outputs.cache-hit }} + rust-cachekey: + description: 'A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"' + value: ${{steps.setup-rust.outputs.cachekey}} + rust-name: + description: 'Rustup's name for the selected version of the toolchain. "1.62.0"' + value: ${{steps.setup-rust.outputs.name}} + swift-version: + description: 'The actual Swift version that was configured.' + value: ${{ steps.setup-swift.outputs.swift-version }} + swift-toolchain: + description: 'JSON formatted toolchain snapshot metadata that was configured.' + value: ${{ steps.setup-swift.outputs.toolchain }} + swift-sdks: + description: 'JSON formatted SDK snapshots metadata that were configured.' + value: ${{ steps.setup-swift.outputs.sdks }} runs: using: 'composite' steps: - - name: Checkout repository - if: inputs.checkout == 'true' - uses: actions/checkout@v4 + # Always perform Harden Runner step + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 with: + egress-policy: audit + + - name: Checkout Code + id: checkout-code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + if: ${{ inputs.checkout == 'true' }} + with: + fetch-depth: ${{ inputs.checkout-fetch-depth }} ref: ${{ inputs.checkout-ref }} token: ${{ inputs.checkout-token }} - - name: Setup Node.js - if: inputs.setup-node == 'true' - uses: actions/setup-node@v4 + - name: Setup Java + id: setup-java + if: ${{ inputs.setup-java == 'true' }} + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 with: - node-version: ${{ inputs.node-version-file != '' && '' || inputs.node-version }} - node-version-file: ${{ inputs.node-version-file }} + distribution: ${{ inputs.java-distribution }} + java-version: ${{ inputs.java-version }} + + - name: Setup Gradle + id: setup-gradle + if: ${{ inputs.setup-gradle == 'true' }} + uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1 + with: + cache-read-only: ${{ inputs.gradle-cache-read-only }} + cache-write-only: ${{ inputs.cache-write-only }} + cache-disabled: ${{ inputs.gradle-cache-disabled }} + gradle-version: ${{ inputs.gradle-version }} + + - name: Setup NodeJS + id: setup-node + if: ${{ inputs.setup-node == 'true' }} + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0 + with: + node-version: ${{ inputs.node-version }} cache: ${{ inputs.node-cache }} + check-latest: ${{ inputs.node-check-latest }} - name: Setup Python - if: inputs.setup-python == 'true' - uses: actions/setup-python@v5 + id: setup-python + if: ${{ inputs.setup-python == 'true' }} + uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 with: python-version: ${{ inputs.python-version }} cache: ${{ inputs.python-cache }} - - name: Setup Java - if: inputs.setup-java == 'true' - uses: actions/setup-java@v4 - with: - java-version: ${{ inputs.java-version }} - distribution: ${{ inputs.java-distribution }} - - name: Setup Go - if: inputs.setup-go == 'true' - uses: actions/setup-go@v5 + id: setup-go + if: ${{ inputs.setup-go == 'true' }} + uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 with: go-version: ${{ inputs.go-version }} cache: ${{ inputs.go-cache }} + - name: Setup Rust + id: setup-rust + if: ${{ inputs.setup-rust == 'true' }} + uses: dtolnay/rust-toolchain@6d653acede28d24f02e3cd41383119e8b1b35921 # v1 + with: + toolchain: ${{ inputs.rust-version }} + targets: ${{ inputs.rust-targets || '' }} + components: ${{ inputs.rust-components || '' }} + + - name: Setup Swift + id: setup-swift + if: ${{ inputs.setup-swift == 'true' }} + uses: SwiftyLab/setup-swift@4bbb093f8c68d1dee1caa8b67c681a3f8fe70a91 # v1.12.0 + with: + swift-version: ${{ inputs.swift-version }} + cache-snapshot: ${{ inputs.swift-cache }} + prefer-oss-toolchain: ${{ inputs.swift-prefer-oss-toolchain }} + sdks: ${{ inputs.swift-sdks || '' }} + branding: - icon: 'play' - color: 'blue' + icon: 'arrow-up-right' + color: 'green' From 01f10ed43688809f78d9b2454412f34463c04fcc Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:24:27 -0600 Subject: [PATCH 02/18] chore: Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Andrew Brandt Signed-off-by: Roger Barker --- .github/workflows/test.yml | 11 ++++++----- action.yml | 10 ++++++---- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bad34a7..880f653 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,14 +20,14 @@ defaults: jobs: test-all: - name: Test Action on ${{ matrix.os }} with ${{ matrix.language }} + name: Test Action on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: - name: Checkout Repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - name: Run Action uses: ./ @@ -57,6 +57,7 @@ jobs: echo "::group::Verify Checkout Outputs" echo "Checkout Ref: ${{ steps.test-all.outputs.checkout-ref }}" echo "Checkout Commit: ${{ steps.test-all.outputs.checkout-commit }}" + echo "::endgroup::" echo "::group::Verify Java Outputs" echo "Java Distribution: ${{ steps.test-all.outputs.java-distribution }}" echo "Java Version: ${{ steps.test-all.outputs.java-version }}" @@ -106,7 +107,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 - name: Run Checkout Action uses: ./ @@ -187,8 +188,8 @@ jobs: uses: ./ id: test-setup-python with: - setup-python: true - python-version: '3.13' + setup-python: true + python-version: '3.13' - name: Verify Python Outputs run: | diff --git a/action.yml b/action.yml index bb8b290..731d4b3 100644 --- a/action.yml +++ b/action.yml @@ -66,7 +66,7 @@ inputs: python-cache: description: 'Used to specify a package manager for caching (pip, pipenv, poetry)' required: false - default: 'false' + setup-go: description: 'Whether to setup Go' required: false @@ -162,10 +162,10 @@ outputs: value: ${{ steps.setup-go.outputs.cache-hit }} rust-cachekey: description: 'A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"' - value: ${{steps.setup-rust.outputs.cachekey}} + value: ${{ steps.setup-rust.outputs.cachekey }} rust-name: description: 'Rustup's name for the selected version of the toolchain. "1.62.0"' - value: ${{steps.setup-rust.outputs.name}} + value: ${{ steps.setup-rust.outputs.name }} swift-version: description: 'The actual Swift version that was configured.' value: ${{ steps.setup-swift.outputs.swift-version }} @@ -188,7 +188,7 @@ runs: - name: Checkout Code id: checkout-code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 if: ${{ inputs.checkout == 'true' }} with: fetch-depth: ${{ inputs.checkout-fetch-depth }} @@ -202,6 +202,7 @@ runs: with: distribution: ${{ inputs.java-distribution }} java-version: ${{ inputs.java-version }} + cache: ${{ inputs.java-cache }} - name: Setup Gradle id: setup-gradle @@ -237,6 +238,7 @@ runs: with: go-version: ${{ inputs.go-version }} cache: ${{ inputs.go-cache }} + architecture: ${{ inputs.go-architecture }} - name: Setup Rust id: setup-rust From 14a03560026cbd7a7be17e340936e22774566195 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:26:25 -0600 Subject: [PATCH 03/18] chore: Add checkout step to all tests Signed-off-by: Roger Barker --- .github/workflows/test.yml | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 880f653..337cbd9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,12 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macos-latest] steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + - name: Checkout Repository uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -106,6 +112,12 @@ jobs: name: Test Checkout Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + - name: Checkout Repository uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -128,6 +140,15 @@ jobs: name: Test Setup Java Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Java Action uses: ./ id: test-setup-java @@ -148,6 +169,15 @@ jobs: name: Test Setup Gradle Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Gradle Action uses: ./ id: test-setup-gradle @@ -166,6 +196,15 @@ jobs: name: Test Setup Node.js Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Node.js Action uses: ./ id: test-setup-node @@ -184,6 +223,15 @@ jobs: name: Test Setup Python Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Python Action uses: ./ id: test-setup-python @@ -203,6 +251,15 @@ jobs: name: Test Setup Go Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Go Action uses: ./ id: test-setup-go @@ -220,6 +277,15 @@ jobs: name: Test Setup Rust Action runs-on: ubuntu-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Rust Action uses: ./ id: test-setup-rust @@ -238,6 +304,15 @@ jobs: name: Test Setup Swift Action runs-on: macos-latest steps: + - name: Harden Runner + id: harden-runner + uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0 + with: + egress-policy: audit + + - name: Checkout Repository + uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 + - name: Run Setup Swift Action uses: ./ id: test-setup-swift From 633f4a095c940bdd009bc96f04f23572091720b0 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:35:18 -0600 Subject: [PATCH 04/18] chore: Add some output in the action Signed-off-by: Roger Barker --- action.yml | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/action.yml b/action.yml index 731d4b3..d04de06 100644 --- a/action.yml +++ b/action.yml @@ -186,6 +186,16 @@ runs: with: egress-policy: audit + - name: Checkout Code Parameters + id: checkout-params + if: ${{ inputs.checkout == 'true' }} + shell: bash + run: | + echo "::group::Checkout Code Parameters" + echo "Ref: ${{ inputs.checkout-ref }}" + echo "Fetch Depth: ${{ inputs.checkout-fetch-depth }}" + echo "::endgroup::" + - name: Checkout Code id: checkout-code uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1 @@ -195,6 +205,17 @@ runs: ref: ${{ inputs.checkout-ref }} token: ${{ inputs.checkout-token }} + - name: Set Up Java Parameters + id: setup-java-params + if: ${{ inputs.setup-java == 'true' }} + shell: bash + run: | + echo "::group::Setting up Java." + echo "Version: ${{ inputs.java-version }}" + echo "Distribution: ${{ inputs.java-distribution }}" + echo "Cache: ${{ inputs.java-cache }}" + echo "::endgroup::" + - name: Setup Java id: setup-java if: ${{ inputs.setup-java == 'true' }} @@ -204,6 +225,18 @@ runs: java-version: ${{ inputs.java-version }} cache: ${{ inputs.java-cache }} + - name: Set Up Gradle Parameters + id: setup-gradle-params + if: ${{ inputs.setup-gradle == 'true' }} + shell: bash + run: | + echo "::group::Setting up Gradle." + echo "Version: ${{ inputs.gradle-version }}" + echo "Cache Disabled: ${{ inputs.gradle-cache-disabled }}" + echo "Cache Read Only: ${{ inputs.gradle-cache-read-only }}" + echo "Cache Write Only: ${{ inputs.cache-write-only }}" + echo "::endgroup::" + - name: Setup Gradle id: setup-gradle if: ${{ inputs.setup-gradle == 'true' }} @@ -214,6 +247,17 @@ runs: cache-disabled: ${{ inputs.gradle-cache-disabled }} gradle-version: ${{ inputs.gradle-version }} + - name: Set Up NodeJS Parameters + id: setup-node-params + if: ${{ inputs.setup-node == 'true' }} + shell: bash + run: | + echo "::group::Setting up NodeJS." + echo "Version: ${{ inputs.node-version }}" + echo "Cache: ${{ inputs.node-cache }}" + echo "Check Latest: ${{ inputs.node-check-latest }}" + echo "::endgroup::" + - name: Setup NodeJS id: setup-node if: ${{ inputs.setup-node == 'true' }} @@ -223,6 +267,16 @@ runs: cache: ${{ inputs.node-cache }} check-latest: ${{ inputs.node-check-latest }} + - name: Set Up Python Parameters + id: setup-python-params + if: ${{ inputs.setup-python == 'true' }} + shell: bash + run: | + echo "::group::Setting up Python." + echo "Version: ${{ inputs.python-version }}" + echo "Cache: ${{ inputs.python-cache }}" + echo "::endgroup::" + - name: Setup Python id: setup-python if: ${{ inputs.setup-python == 'true' }} @@ -231,6 +285,17 @@ runs: python-version: ${{ inputs.python-version }} cache: ${{ inputs.python-cache }} + - name: Set Up Go Parameters + id: setup-go-params + if: ${{ inputs.setup-go == 'true' }} + shell: bash + run: | + echo "::group::Setting up Go." + echo "Version: ${{ inputs.go-version }}" + echo "Cache: ${{ inputs.go-cache }}" + echo "Architecture: ${{ inputs.go-architecture }}" + echo "::endgroup::" + - name: Setup Go id: setup-go if: ${{ inputs.setup-go == 'true' }} @@ -240,6 +305,17 @@ runs: cache: ${{ inputs.go-cache }} architecture: ${{ inputs.go-architecture }} + - name: Set Up Rust Parameters + id: setup-rust-params + if: ${{ inputs.setup-rust == 'true' }} + shell: bash + run: | + echo "::group::Setting up Rust." + echo "Version: ${{ inputs.rust-version }}" + echo "Targets: ${{ inputs.rust-targets }}" + echo "Components: ${{ inputs.rust-components }}" + echo "::endgroup::" + - name: Setup Rust id: setup-rust if: ${{ inputs.setup-rust == 'true' }} @@ -249,6 +325,18 @@ runs: targets: ${{ inputs.rust-targets || '' }} components: ${{ inputs.rust-components || '' }} + - name: Set Up Swift Parameters + id: setup-swift-params + if: ${{ inputs.setup-swift == 'true' }} + shell: bash + run: | + echo "::group::Setting up Swift." + echo "Version: ${{ inputs.swift-version }}" + echo "Cache: ${{ inputs.swift-cache }}" + echo "Prefer OSS Toolchain: ${{ inputs.swift-prefer-oss-toolchain }}" + echo "SDKs: ${{ inputs.swift-sdks }}" + echo "::endgroup::" + - name: Setup Swift id: setup-swift if: ${{ inputs.setup-swift == 'true' }} From b8fd03109a7706ad1c6c958d32b12aba443b9a45 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:40:25 -0600 Subject: [PATCH 05/18] chore: fix typo Signed-off-by: Roger Barker --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d04de06..8a94670 100644 --- a/action.yml +++ b/action.yml @@ -164,7 +164,7 @@ outputs: description: 'A short hash of the rustc version, appropriate for use as a cache key. "20220627a831"' value: ${{ steps.setup-rust.outputs.cachekey }} rust-name: - description: 'Rustup's name for the selected version of the toolchain. "1.62.0"' + description: 'Rustups name for the selected version of the toolchain. "1.62.0"' value: ${{ steps.setup-rust.outputs.name }} swift-version: description: 'The actual Swift version that was configured.' From e3b4da08708770b6bd7f22bd2aa90417427011e3 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:44:27 -0600 Subject: [PATCH 06/18] chore: Update checkout ref Signed-off-by: Roger Barker --- .github/workflows/test.yml | 3 ++- action.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 337cbd9..9957188 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,8 @@ jobs: with: checkout: true checkout-fetch-depth: 0 - checkout-ref: main + checkout-ref: 2-update-composite-action-for-real-life + checkout-token: ${{ secrets.GITHUB_TOKEN }} setup-java: true java-distribution: 'temurin' java-version: '17' diff --git a/action.yml b/action.yml index 8a94670..797909a 100644 --- a/action.yml +++ b/action.yml @@ -203,7 +203,7 @@ runs: with: fetch-depth: ${{ inputs.checkout-fetch-depth }} ref: ${{ inputs.checkout-ref }} - token: ${{ inputs.checkout-token }} + token: ${{ inputs.checkout-token || secrets.GITHUB_TOKEN }} - name: Set Up Java Parameters id: setup-java-params From f23bd0ca41272ef70d117320391a6aed4d1ef4bd Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:45:22 -0600 Subject: [PATCH 07/18] chore: fix typo Signed-off-by: Roger Barker --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 797909a..8a94670 100644 --- a/action.yml +++ b/action.yml @@ -203,7 +203,7 @@ runs: with: fetch-depth: ${{ inputs.checkout-fetch-depth }} ref: ${{ inputs.checkout-ref }} - token: ${{ inputs.checkout-token || secrets.GITHUB_TOKEN }} + token: ${{ inputs.checkout-token }} - name: Set Up Java Parameters id: setup-java-params From 4ec9f5c46e3e2273dc5440eb4b0cd6448bc4ce7b Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:47:33 -0600 Subject: [PATCH 08/18] chore: Update test checkout Signed-off-by: Roger Barker --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9957188..1a47a7e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -129,6 +129,7 @@ jobs: checkout: true checkout-fetch-depth: 0 checkout-ref: main + checkout-token: ${{ secrets.GITHUB_TOKEN }} - name: Verify Checkout Outputs run: | From f6cb08550dc244ebe01cf85feae2f14f08c77bd4 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 12:57:46 -0600 Subject: [PATCH 09/18] chore: Treat booleans as booleans Signed-off-by: Roger Barker --- action.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 8a94670..081b8ab 100644 --- a/action.yml +++ b/action.yml @@ -37,7 +37,7 @@ inputs: description: 'Java distribution (temurin, zulu, adopt, etc.)' required: false java-cache: - description: 'Whether to cache Java dependencies' + description: 'Name of the build platform to cache dependencies. It can be "maven", "gradle" or "sbt".' required: false setup-gradle: description: 'Whether to setup Gradle' @@ -66,7 +66,6 @@ inputs: python-cache: description: 'Used to specify a package manager for caching (pip, pipenv, poetry)' required: false - setup-go: description: 'Whether to setup Go' required: false @@ -77,6 +76,7 @@ inputs: go-cache: description: 'Whether to cache Go modules' required: false + default: 'true' go-architecture: description: 'Target architecture for Go to use. Examples: x86, x64. Will use system architecture by default.' required: false @@ -242,9 +242,9 @@ runs: if: ${{ inputs.setup-gradle == 'true' }} uses: gradle/actions/setup-gradle@ac638b010cf58a27ee6c972d7336334ccaf61c96 # v4.4.1 with: - cache-read-only: ${{ inputs.gradle-cache-read-only }} - cache-write-only: ${{ inputs.cache-write-only }} - cache-disabled: ${{ inputs.gradle-cache-disabled }} + cache-read-only: ${{ inputs.gradle-cache-read-only == 'true' }} + cache-write-only: ${{ inputs.cache-write-only == 'true' }} + cache-disabled: ${{ inputs.gradle-cache-disabled == 'true' }} gradle-version: ${{ inputs.gradle-version }} - name: Set Up NodeJS Parameters @@ -265,7 +265,7 @@ runs: with: node-version: ${{ inputs.node-version }} cache: ${{ inputs.node-cache }} - check-latest: ${{ inputs.node-check-latest }} + check-latest: ${{ inputs.node-check-latest == 'true' }} - name: Set Up Python Parameters id: setup-python-params @@ -302,7 +302,7 @@ runs: uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0 with: go-version: ${{ inputs.go-version }} - cache: ${{ inputs.go-cache }} + cache: ${{ inputs.go-cache == 'true' }} architecture: ${{ inputs.go-architecture }} - name: Set Up Rust Parameters @@ -343,8 +343,8 @@ runs: uses: SwiftyLab/setup-swift@4bbb093f8c68d1dee1caa8b67c681a3f8fe70a91 # v1.12.0 with: swift-version: ${{ inputs.swift-version }} - cache-snapshot: ${{ inputs.swift-cache }} - prefer-oss-toolchain: ${{ inputs.swift-prefer-oss-toolchain }} + cache-snapshot: ${{ inputs.swift-cache == 'true' }} + prefer-oss-toolchain: ${{ inputs.swift-prefer-oss-toolchain == 'true' }} sdks: ${{ inputs.swift-sdks || '' }} branding: From b23a84fa8705e2e6273cdf7e39f02c48a5c64fcb Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 13:01:04 -0600 Subject: [PATCH 10/18] chore: Remove default setup-go Signed-off-by: Roger Barker --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 081b8ab..3c16438 100644 --- a/action.yml +++ b/action.yml @@ -69,7 +69,6 @@ inputs: setup-go: description: 'Whether to setup Go' required: false - default: 'true' go-version: description: 'Go version to use' required: false From f4a8c1d3d9cee7ae93e049d51261e1801b04f58e Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 13:19:08 -0600 Subject: [PATCH 11/18] chore: Run all tests on ubuntu-latest Signed-off-by: Roger Barker --- .github/workflows/test.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1a47a7e..01d7dd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,10 +21,7 @@ defaults: jobs: test-all: name: Test Action on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + runs-on: ubuntu-latest steps: - name: Harden Runner id: harden-runner From 2b84d2c916fad24068b1eb308239a8652d01caf4 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 13:23:17 -0600 Subject: [PATCH 12/18] chore: Update title in test all Signed-off-by: Roger Barker --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 01d7dd0..dc39b53 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ defaults: jobs: test-all: - name: Test Action on ${{ matrix.os }} + name: Test All Features runs-on: ubuntu-latest steps: - name: Harden Runner From 31ad1a0747bf24285278ed1279ffd42bc321a8b2 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 13:47:54 -0600 Subject: [PATCH 13/18] chore: Update README.md Signed-off-by: Roger Barker --- README.md | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++- action.yml | 1 + 2 files changed, 200 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 99faddd..7eb06f4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,200 @@ -# Initialize Github Job +# Initialize GitHub Job -TBD +Common steps for initializing a job for GitHub actions. This composite action consolidates setup steps for multiple programming languages and tools. + +## Features + +- Security hardening with Step Security's Harden Runner +- Repository checkout with configurable options +- Multi-language support (Node.js, Java, Python, Go, Rust, Swift) +- Build tool setup (Gradle) +- Automatic caching for dependencies and build artifacts + +## Usage + +```yaml +- name: Initialize Job + uses: PandasWhoCode/initialize-github-job@v1 + with: + checkout: 'true' + checkout-token: '${{ secrets.GITHUB_TOKEN }}' + setup-node: 'true' + node-version: '20' + node-cache: 'npm' +``` + +### Inputs + +**Repository Checkout** + +| Input | Description | Required | Default | +|----------------------|----------------------------------------------------------|----------|---------| +| checkout | Whether to checkout the repository | No | - | +| checkout-ref | The branch, tag or SHA to checkout | No | - | +| checkout-token | Personal access token (PAT) used to fetch the repository | No | - | +| checkout-fetch-depth | Depth of commit history to fetch | No | 0 | + +**Node.js** + +| Input | Description | Required | Default | +|-------------------|-------------------------------------------------|----------|---------| +| setup-node | Whether to setup Node.js | No | - | +| node-version | Node.js version to use | No | - | +| node-cache | Package manager for caching (npm, yarn, pnpm) | No | - | +| node-check-latest | Whether to check for the latest Node.js version | No | - | + +**Java** + +| Input | Description | Required | Default | +|-------------------|-----------------------------------------------------------|----------|---------| +| setup-java | Whether to setup Java | No | - | +| java-version | Java version to use | No | - | +| java-distribution | Java distribution (temurin, zulu, adopt, etc.) | No | - | +| java-cache | Build platform to cache dependencies (maven, gradle, sbt) | No | - | + +**Gradle** + +| Input | Description | Required | Default | +|------------------------|--------------------------------------------------------------------------------------------|----------|---------| +| setup-gradle | Whether to setup Gradle | No | - | +| gradle-version | Gradle version to use | No | wrapper | +| gradle-cache-disabled | Whether to disable Gradle caching | No | false | +| gradle-cache-read-only | Whether to use read-only caching for Gradle | No | - | +| cache-write-only | When true, entries will not be restored from cache but will be saved at the end of the Job | No | false | + +**Python** + +| Input | Description | Required | Default | +|----------------|---------------------------------------------------|----------|---------| +| setup-python | Whether to setup Python | No | - | +| python-version | Python version to use | No | - | +| python-cache | Package manager for caching (pip, pipenv, poetry) | No | - | + +**Go** + +| Input | Description | Required | Default | +|-----------------|--------------------------------|----------|---------| +| setup-go | Whether to setup Go | No | - | +| go-version | Go version to use | No | - | +| go-cache | Whether to cache Go modules | No | true | +| go-architecture | Target architecture (x86, x64) | No | - | + + +**Rust** + +| Input | Description | Required | Default | +|-----------------|---------------------------------------------------|----------|---------| +| setup-rust | Whether to setup Rust | No | - | +| rust-version | Rust version to use | No | - | +| rust-targets | Comma-separated list of target triples to install | No | - | +| rust-components | Comma-separated list of components to install | No | - | + +**Swift** + +| Input | Description | Required | Default | +|----------------------------|----------------------------------------------------------|----------|---------| +| setup-swift | Whether to setup Swift | No | - | +| swift-version | Swift version to use | No | - | +| swift-cache | Whether to cache downloaded toolchain snapshots | No | true | +| swift-prefer-oss-toolchain | Whether to prefer Swift open source toolchain over Xcode | No | false | +| swift-sdks | Semi-colon separated list of Swift SDKs to install | No | - | + +### Outputs + +**Checkout Outputs** + +- `checkout-ref`: The branch, tag or SHA that was checked out +- `checkout-commit`: The commit SHA that was checked out + +**Java Outputs** + +- `java-distribution`: Distribution of Java that has been installed +- `java-version`: Actual version of the java environment that has been installed +- `java-path`: Path to where the java environment has been installed +- `java-cache-hit`: Boolean indicating if cache was hit + +**Gradle Outputs** + +- `gradle-build-scan-url`: Link to the Build Scan® generated by a Gradle build +- `gradle-dependency-graph-file`: Path to the GitHub Dependency Graph snapshot file +- `gradle-version`: Version of Gradle that was setup + +**Node.js Outputs** +- `node-cache-hit`: Boolean indicating if cache was hit +- `node-version`: The installed node version + +**Python Outputs** + +- `python-version`: The installed Python or PyPy version +- `python-cache-hit`: Boolean indicating if cache was hit +- `python-path`: The absolute path to the Python or PyPy executable + + +**Go Outputs** + +- `go-version`: The installed Go version +- `go-cache-hit`: Boolean indicating if cache was hit + +**Rust Outputs** + +- `rust-cachekey`: A short hash of the rustc version for use as a cache key +- `rust-name`: Rustups name for the selected version of the toolchain + +**Swift Outputs** + +- `swift-version`: The actual Swift version that was configured +- `swift-toolchain`: JSON formatted toolchain snapshot metadata +- `swift-sdks`: JSON formatted SDK snapshots metadata + +## Examples + +**Node.js Project** + +```yaml +- uses: PandasWhoCode/initialize-github-job@v1 + with: + checkout: 'true' + checkout-token: '${{ secrets.GITHUB_TOKEN }}' + setup-node: 'true' + node-version: '20' + node-cache: 'npm' +``` + +**Java with Gradle** + +```yaml +- uses: PandasWhoCode/initialize-github-job@v1 + with: + checkout: 'true' + setup-java: 'true' + java-version: '21' + java-distribution: 'temurin' + setup-gradle: 'true' +``` + +**Python Project** + +```yaml +- uses: PandasWhoCode/initialize-github-job@v1 + with: + setup-python: 'true' + python-version: '3.12' + python-cache: 'pip' +``` + +**Multi-Language Setup** + +```yaml +- uses: PandasWhoCode/initialize-github-job@v1 + with: + checkout: 'true' + setup-node: 'true' + node-version: '20' + node-cache: 'npm' + setup-python: 'true' + python-version: '3.12' + python-cache: 'pip' +``` + +## License +This repository is licensed under the Apache 2.0 License. See the [LICENSE](LICENSE) file for details. diff --git a/action.yml b/action.yml index 3c16438..53ba816 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,7 @@ inputs: checkout-fetch-depth: description: 'Depth of commit history to fetch' required: false + default: '0' setup-node: description: 'Whether to setup Node.js' required: false From a8836f89a287756866ca44fedc1b817d473a6dc7 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 14:32:46 -0600 Subject: [PATCH 14/18] chore: resolve PR feedback Signed-off-by: Roger Barker --- .github/workflows/test.yml | 8 ++++---- README.md | 19 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc39b53..8007bbc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,9 +44,9 @@ jobs: java-distribution: 'temurin' java-version: '17' setup-gradle: true - gradle-version: '7.5' + gradle-version: '9' setup-node: true - node-version: '18' + node-version: '24' setup-python: true python-version: '3.9' setup-go: true @@ -182,7 +182,7 @@ jobs: id: test-setup-gradle with: setup-gradle: true - gradle-version: '7.5' + gradle-version: '9' - name: Verify Gradle Outputs run: | @@ -209,7 +209,7 @@ jobs: id: test-setup-node with: setup-node: true - node-version: '18' + node-version: '22' - name: Verify Node.js Outputs run: | diff --git a/README.md b/README.md index 7eb06f4..a8f7ad5 100644 --- a/README.md +++ b/README.md @@ -34,15 +34,6 @@ Common steps for initializing a job for GitHub actions. This composite action co | checkout-token | Personal access token (PAT) used to fetch the repository | No | - | | checkout-fetch-depth | Depth of commit history to fetch | No | 0 | -**Node.js** - -| Input | Description | Required | Default | -|-------------------|-------------------------------------------------|----------|---------| -| setup-node | Whether to setup Node.js | No | - | -| node-version | Node.js version to use | No | - | -| node-cache | Package manager for caching (npm, yarn, pnpm) | No | - | -| node-check-latest | Whether to check for the latest Node.js version | No | - | - **Java** | Input | Description | Required | Default | @@ -62,6 +53,15 @@ Common steps for initializing a job for GitHub actions. This composite action co | gradle-cache-read-only | Whether to use read-only caching for Gradle | No | - | | cache-write-only | When true, entries will not be restored from cache but will be saved at the end of the Job | No | false | +**Node.js** + +| Input | Description | Required | Default | +|-------------------|-------------------------------------------------|----------|---------| +| setup-node | Whether to setup Node.js | No | - | +| node-version | Node.js version to use | No | - | +| node-cache | Package manager for caching (npm, yarn, pnpm) | No | - | +| node-check-latest | Whether to check for the latest Node.js version | No | - | + **Python** | Input | Description | Required | Default | @@ -129,7 +129,6 @@ Common steps for initializing a job for GitHub actions. This composite action co - `python-cache-hit`: Boolean indicating if cache was hit - `python-path`: The absolute path to the Python or PyPy executable - **Go Outputs** - `go-version`: The installed Go version From 4fbb4aeeef380d6581e9bacce39fe05d07008a28 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 14:33:51 -0600 Subject: [PATCH 15/18] chore: use recent java version Signed-off-by: Roger Barker --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8007bbc..416cad8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -42,7 +42,7 @@ jobs: checkout-token: ${{ secrets.GITHUB_TOKEN }} setup-java: true java-distribution: 'temurin' - java-version: '17' + java-version: '25' setup-gradle: true gradle-version: '9' setup-node: true @@ -154,7 +154,7 @@ jobs: with: setup-java: true java-distribution: 'temurin' - java-version: '17' + java-version: '25' - name: Verify Java Outputs run: | From 864bf1c3d1a35e78da448e76e6a68af68e1f2259 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 14:36:27 -0600 Subject: [PATCH 16/18] chore: update minor things Signed-off-by: Roger Barker --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 416cad8..a6cd0eb 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: java-distribution: 'temurin' java-version: '25' setup-gradle: true - gradle-version: '9' + gradle-version: '9.2' setup-node: true node-version: '24' setup-python: true @@ -182,7 +182,7 @@ jobs: id: test-setup-gradle with: setup-gradle: true - gradle-version: '9' + gradle-version: '9.2' - name: Verify Gradle Outputs run: | From 56f1b0bb47b0ec75ea483212e602ba863a73cb68 Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 14:36:53 -0600 Subject: [PATCH 17/18] chore: update more minor things Signed-off-by: Roger Barker --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a6cd0eb..fa41693 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: with: checkout: true checkout-fetch-depth: 0 - checkout-ref: 2-update-composite-action-for-real-life + checkout-ref: main checkout-token: ${{ secrets.GITHUB_TOKEN }} setup-java: true java-distribution: 'temurin' From 138bbf98773ef3bdade43c95f4358b06e4c29f0a Mon Sep 17 00:00:00 2001 From: Roger Barker Date: Wed, 19 Nov 2025 14:40:03 -0600 Subject: [PATCH 18/18] chore: use explicit gradle version Signed-off-by: Roger Barker --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa41693..c2c25a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,7 @@ jobs: java-distribution: 'temurin' java-version: '25' setup-gradle: true - gradle-version: '9.2' + gradle-version: '9.2.1' setup-node: true node-version: '24' setup-python: true @@ -182,7 +182,7 @@ jobs: id: test-setup-gradle with: setup-gradle: true - gradle-version: '9.2' + gradle-version: '9.2.1' - name: Verify Gradle Outputs run: |