From 29c495413d8e107ca67bce6253de742f9112a49d Mon Sep 17 00:00:00 2001 From: Dimi Kot Date: Tue, 27 Feb 2024 23:48:22 -0800 Subject: [PATCH] Add action.yml and self-test Pull Request: https://github.com/dimikot/ci-storage/pull/1 (main) --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++ action.yml | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d045c9a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: "CI Full Run" +on: + pull_request: + branches: + - main + - grok/*/* +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Create dummy file + run: echo "dummy" > dummy.txt + - name: Test store + uses: ./ + with: + action: "store" + storage-host: "" + - name: Remove dummy file + run: rm dummy.txt + - name: Test load + uses: ./ + with: + action: "load" + storage-host: "" + - name: Check that dummy file was restored + run: | + ls -la ~/ci-storage + [ "$(cat dummy.txt)" = "dummy" ] || { echo "dummy.txt was not restored"; exit 1; } diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..44bcd18 --- /dev/null +++ b/action.yml @@ -0,0 +1,43 @@ +name: "CI Storage" +description: "Quickly stores the content of huge work directory with low percentage of changed files in the storage on a remote host, or loads the content from the storage." +inputs: + action: + description: "What to do (store or load)." + required: true + storage-host: + description: "Storage host in the format [user@]host; it must have password-free SSH key access." + required: true + storage-dir: + description: "Storage directory on the remote host. If not set, uses the ci-storage tool default ~/ci-storage." + required: false + storage-max-age-sec: + description: "Remove slots created earlier than this many seconds ago. If not set, uses the ci-storage tool default 4 hours." + required: false + slot-id: + description: 'Id of the slot to store to or load from; use "*" to load a random most recent slot. If empty, uses "$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT" value.' + required: false + local-dir: + description: 'Local directory path to store from or load to. If not set, uses "." (the current work directory).' + required: false + exclude: + description: "Newline separated exclude pattern(s) for rsync." + required: false + verbose: + description: "If set, prints the list of transferred files." + type: boolean + required: false +runs: + using: "composite" + steps: + - name: Run ci-storage ${{ inputs.action }} + run: > + pwd && ./ci-storage + --storage-host="${{ inputs.storage-host || '' }}" + --storage-dir="${{ inputs.storage-dir || '' }}" + --storage-max-age-sec="${{ inputs.storage-max-age-sec || '' }}" + --slot-id="${{ inputs.slot-id || format('{0}-{1}', github.run_id, github.run_attempt) }}" + --local-dir="${{ inputs.local-dir || '.' }}" + --exclude="${{ inputs.exclude || '' }}" + ${{ inputs.verbose && '--verbose' || '' }} + ${{ inputs.action }} + shell: bash