Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Deployer/testing shell script #6

Open
wants to merge 75 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
1b196a3
feat: add 2 different outputs
ASuciuX Nov 30, 2023
88ae8f5
feat: remove duplicated line output
ASuciuX Nov 30, 2023
455fac5
fix: remove the only line from file
ASuciuX Nov 30, 2023
2d2b9d8
feat: append the PR files to Stable files
ASuciuX Nov 30, 2023
17cffc9
fix: working example with the same line number
ASuciuX Nov 30, 2023
4f2264b
feat: adding cache upload workflow
ASuciuX Nov 30, 2023
860c3fb
feat: added current branch to upload cache
ASuciuX Nov 30, 2023
a8878dc
feat: add trigger on pr
ASuciuX Nov 30, 2023
394f406
feat: restructure the code for mutations
ASuciuX Nov 30, 2023
d34b694
feat: move outputs to trials folder
ASuciuX Nov 30, 2023
aad88ac
fix: commented unnecessary deletion
ASuciuX Nov 30, 2023
fd9e4c0
add some info and better naming
ASuciuX Nov 30, 2023
cf22f50
fix: working append-match line
ASuciuX Nov 30, 2023
773499a
feat: stx-genesis output
ASuciuX Nov 30, 2023
d42a286
feat: updated file names to lib and renamed output stable
ASuciuX Nov 30, 2023
544531e
feat: create stable packages output
ASuciuX Nov 30, 2023
b0aa45c
feat: docs beginning
ASuciuX Nov 30, 2023
4b14963
feat: updated create stable
ASuciuX Nov 30, 2023
97695b1
feat: stable sh outputs in the right folder
ASuciuX Nov 30, 2023
717f2ce
feat: append match package v1
ASuciuX Nov 30, 2023
acdac59
feat: sed match pattern
ASuciuX Nov 30, 2023
783c4d4
feat: in progress exact matcher with nr line
ASuciuX Dec 1, 2023
a64915c
feat: blocked at pattern on file
ASuciuX Dec 1, 2023
1dd2e31
fix: working pattern with any line number
ASuciuX Dec 1, 2023
c0818f6
fix: works with the more general version using .*
ASuciuX Dec 1, 2023
9de033b
feat: remove extras
ASuciuX Dec 1, 2023
f50b646
fix: git diff called from scripts folder
ASuciuX Dec 1, 2023
fdaf4fa
feat: feature to add functions from newly created files
ASuciuX Dec 1, 2023
90b436d
feat: starting with CI
ASuciuX Dec 1, 2023
a0114c3
feat: add stable output to artifacts
ASuciuX Dec 1, 2023
8162aa5
feat: incremental artifact update CI
ASuciuX Dec 1, 2023
c1cc28c
feat: try to get the articat from previous workflow
ASuciuX Dec 1, 2023
8b8cc79
feat: try with catche
ASuciuX Dec 1, 2023
6a38212
feat: show old cache
ASuciuX Dec 1, 2023
24929b0
feat: update cache with new data
ASuciuX Dec 1, 2023
dfb8fde
feat: updated permissions to script
ASuciuX Dec 1, 2023
cd0801d
feat: append 2 simple lines to check overwrite cache
ASuciuX Dec 1, 2023
cd2a582
feat: try again
ASuciuX Dec 1, 2023
b99636b
feat: added retry to save cache
ASuciuX Dec 1, 2023
fca8ec8
feat: upload mutants initial state cache
ASuciuX Dec 4, 2023
3664260
feat: fixed name of print directory
ASuciuX Dec 4, 2023
531aede
feat: added update cache functionality
ASuciuX Dec 4, 2023
12386ee
feat: added todo comment for retrying the save
ASuciuX Dec 4, 2023
c0bd056
feat: added last commit hash to cache
ASuciuX Dec 5, 2023
767e542
feat: mutation testing for differences, added 2 functions to test mut…
ASuciuX Dec 5, 2023
53b4948
feat: changed flags on commit file because it doesn't retain it in cache
ASuciuX Dec 5, 2023
ff272b3
feat: update location of last commit file
ASuciuX Dec 5, 2023
3631cbb
feat: try again with the new file location
ASuciuX Dec 5, 2023
22f44e2
feat: install cargo-mutants crate
ASuciuX Dec 5, 2023
227f13f
feat: try running the diffs again
ASuciuX Dec 5, 2023
55e66bb
feat: updated file location in git diff script
ASuciuX Dec 5, 2023
8498191
feat: try again
ASuciuX Dec 5, 2023
131d0ce
feat: fixed script errors, writing the git diff to file
ASuciuX Dec 5, 2023
a92e4f8
feat: try again
ASuciuX Dec 5, 2023
921f961
feat: update arg for git diff in script
ASuciuX Dec 5, 2023
5add038
feat: try again
ASuciuX Dec 5, 2023
a084535
feat: updated checkout to fetch all commits
ASuciuX Dec 5, 2023
21178cb
feat: try again
ASuciuX Dec 5, 2023
f73b32d
feat: re-upload the cache with the initial files
ASuciuX Dec 5, 2023
5627f1c
feat: workflow failure in case of missed/timeout mutants
ASuciuX Dec 5, 2023
efbae73
feat: new function to test exit on missed mutations
ASuciuX Dec 5, 2023
5424adf
feat: updated name of file to check from 'caught' to 'missed'
ASuciuX Dec 5, 2023
d414482
feat: fail workflow on missed/timeout mutations on pr (different work…
ASuciuX Dec 5, 2023
ce87fc5
feat: scripts to remove the deleted fn's mutations from stable output
ASuciuX Dec 6, 2023
d5cd927
feat: ci workflows updated to correctly use the scripts
ASuciuX Dec 7, 2023
b07c362
feat: updated scripts names in ci
ASuciuX Dec 7, 2023
a804dff
feat: removed git-diff.sh script, running directly in workflow
ASuciuX Dec 8, 2023
49befc1
feat: update ci workflow file names
ASuciuX Dec 8, 2023
80413e9
feat: checking exit code of cargo mutants in pr filtering
ASuciuX Dec 8, 2023
e41727a
feat: continue with checking output even if mutants command fails
ASuciuX Dec 8, 2023
961a7ff
feat: move the exit code checking where the command is ran
ASuciuX Dec 8, 2023
e4f1447
feat: removed || true which changes the exit code
ASuciuX Dec 8, 2023
08f002a
feat: disable and re-enable exit on error for 'cargo mutants' command
ASuciuX Dec 8, 2023
9b27bb8
feat: added base branch name to mutants logging after merge
ASuciuX Dec 8, 2023
51dcd8c
feat: mutation testing on pr using actions repo
ASuciuX Dec 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,31 +75,6 @@ jobs:
base: ${{ env.BRANCH_NAME }}
head: HEAD

## Mutants testing: Execute on PR on packages that have tested functions modified
incremental-mutants:
name: Incremental Mutants Testing
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Relative diff
run: |
git branch -av
git diff origin/${{ github.base_ref }}.. | tee git.diff
- uses: Swatinem/rust-cache@v2
- run: cargo install cargo-mutants
- name: Mutants
run: |
cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff || true
- name: Archive mutants.out
uses: actions/upload-artifact@v3
if: always()
with:
name: mutants-incremental.out
path: mutants.out

###############################################
## Build Tagged Release
###############################################
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/filter-pr-mutants.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Tracking PR Mutants

on:
pull_request:

jobs:
# Mutants testing: Execute on PR on packages that have functions modified, and fail the workflow if there are missed or timeout mutations
incremental-mutants:
name: Incremental Mutants Testing

runs-on: ubuntu-latest

steps:
- name: Run filtering pr mutants from actions
uses: ASuciuX/actions/mutation-testing/filter-pr@feat/mutation-testing
# name: Tracking PR Mutants

# on:
# pull_request:

# jobs:
# # Mutants testing: Execute on PR on packages that have functions modified, and fail the workflow if there are missed or timeout mutations
# incremental-mutants:
# name: Incremental Mutants Testing

# runs-on: ubuntu-latest

# if: github.event_name == 'pull_request'

# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0

# - name: Relative diff
# run: |
# git branch -av
# git diff origin/${{ github.base_ref }}.. | tee git.diff
# working-directory: ./mutation-testing/scripts

# - uses: Swatinem/rust-cache@v2

# - run: cargo install cargo-mutants

# - name: Remove deleted file lines from git.diff file
# run: ./remove-deleted-file-lines.sh
# working-directory: ./mutation-testing/scripts

# - name: Run mutants and check the exit code of the command, fail the workflow if mutations are not caught
# run: |
# set +e # Disable immediate exit on error
# cargo mutants --no-shuffle -j 2 -vV --in-diff git.diff --output ./
# exit_code=$?
# set -e # Enable immediate exit on error again

# case $exit_code in
# 0)
# if [ -s ./mutants.out/unviable.txt ]; then
# echo "-------------"
# echo "Found unviable mutants:"
# cat ./mutants.out/unviable.txt
# exit 1
# fi
# echo "All new and updated functions are caught!"
# ;;
# 1)
# echo "Invalid command line arguments!"
# exit 1
# ;;
# 2 | 3)
# if [ -s ./mutants.out/missed.txt ]; then
# echo "Found missed mutants:"
# cat ./mutants.out/missed.txt
# fi
# if [ -s ./mutants.out/timeout.txt ]; then
# echo "-------------"
# echo "Found timeout mutants:"
# cat ./mutants.out/timeout.txt
# fi
# if [ -s ./mutants.out/unviable.txt ]; then
# echo "-------------"
# echo "Found unviable mutants:"
# cat ./mutants.out/unviable.txt
# fi
# exit 1
# ;;
# 4)
# echo "Building the packages failed without any mutations!"
# exit 1
# ;;
# *)
# echo "Unknown exit code: $exit_code"
# exit 1
# ;;
# esac
# working-directory: ./mutation-testing/scripts
265 changes: 265 additions & 0 deletions .github/workflows/log-mutants.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
name: Logging Mutants

# only run on push in order to update the cache output
# flow:
# restore cache
# install cargo-mutants crate in order to run the 'cargo mutants' command
# create a file with the current commit hash if a previous one doesn't exist, then print it
# run the script that handles the 'cargo mutants' command on the differences between the latest updates and the last commit where it was ran
# overwrite the previous commit hash with the current one for the following run
# delete the old cache
# save the new cache with the updated mutants

on:
push:
branches:
- master
- develop
- next
- deployer/testing-shell-script

jobs:
save_cache:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Restore mutants-output cached folder
id: cache-restore
uses: actions/cache/restore@v3
with:
path: ./mutation-testing/packages-output
key: mutants-stable-${{ github.ref_name }}

- name: Install cargo-mutants crate
run: cargo install cargo-mutants

- name: Create file with current commit hash if it doesn't exist
run: |
if [ ! -f last_commit_hash.txt ]; then
echo "${{ github.sha }}" > last_commit_hash.txt
fi
working-directory: ./mutation-testing/packages-output

- name: Print old commit hash
run: cat ./mutation-testing/packages-output/last_commit_hash.txt

- name: Create git.diff file
run: |
last_commit_hash=$(<../packages-output/last_commit_hash.txt)
git diff $last_commit_hash > git.diff
working-directory: ./mutation-testing/scripts

- name: Remove deleted functions from output files
run: ./remove-deleted-functions-from-output.sh
working-directory: ./mutation-testing/scripts

- name: Remove deleted file lines from git.diff file
run: ./remove-deleted-file-lines.sh
working-directory: ./mutation-testing/scripts

- name: Run the mutation testing on the differences
run: |
if [ -f ./packages-output/last_commit_hash.txt ]; then
cargo mutants --no-shuffle -j 2 -vV --in-diff ./scripts/git.diff --output temp/
fi
working-directory: ./mutation-testing

- name: Update the content from the stable output
run: bash append-match-package.sh
working-directory: ./mutation-testing/scripts

- name: Re-write the old commit hash with the current one
run: |
echo "${{ github.sha }}" > last_commit_hash.txt
working-directory: ./mutation-testing/packages-output

- name: Print new commit hash
run: cat ./mutation-testing/packages-output/last_commit_hash.txt

- name: Delete Previous Cache
if: ${{ steps.cache-restore.outputs.cache-hit }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "mutants-stable-${{ github.ref_name }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# TODO: feature for retrying the save in case it fails for any reason (in order not to lose the cache)
- name: Save Cache
uses: actions/cache/save@v3
with:
path: ./mutation-testing/packages-output
key: mutants-stable-${{ github.ref_name }}

# cache_mutants:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout the latest code
# id: git_checkout
# uses: actions/checkout@v3
# - name: Cache mutants-initial folder
# uses: actions/cache@v3
# with:
# path: mutants-initial
# key: mutants-initial
# - name: Print caught mutants
# run: cat mutants-initial/caught.txt
# - name: Print missed mutants
# run: cat mutants-initial/missed.txt
# - name: Print unviable mutants
# run: cat mutants-initial/unviable.txt
# - name: Print timeout mutants
# run: cat mutants-initial/timeout.txt

# Upload cache stable output version
# cache_mutants_output:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout the latest code
# id: git_checkout
# uses: actions/checkout@v3
# - name: Cache mutants-initial folder
# uses: actions/cache@v3
# with:
# path: mutation-testing/packages-output
# key: mutants-stable-develop
# # - name: Print caught mutants
# # run: cat mutants-initial/caught.txt

# ## Mutants testing: Execute on push on packages that have tested functions modified
# cache_update_output:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout the latest code
# id: git_checkout
# uses: actions/checkout@v3
# - name: Restore mutants-output cached folder
# uses: actions/cache/restore@v3
# with:
# path: mutation-testing/packages-output
# key: mutants-stable-develop
# - name: Print caught mutants
# run: cat mutation-testing/packages-output/pox-locking/missed.txt
# - run: cargo install cargo-mutants
# # - name: Update stable mutants with modified functions
# # run: ./git-diff.sh
# # working-directory: mutation-testing/scripts
# # - name: Print updated missed mutants
# # run: cat mutation-testing/packages-output/pox-locking/missed.txt
# - name: Append 2 line to one file
# run: |
# echo "text 1" >> missed.txt
# echo "text 2" >> missed.txt
# working-directory: mutation-testing/packages-output/pox-locking
# - name: outshow new cached file
# run: cat missed.txt
# working-directory: mutation-testing/packages-output/pox-locking
# # - name: Cache mutants-initial folder
# # uses: actions/cache/save@v3
# # with:
# # path: mutation-testing/packages-output
# # key: mutants-stable-develop
# - name: Save Cache
# uses: Wandalen/wretry.action@a163f62ae554a8f3cbe27b23db15b60c0ae2e93c # v1.3.0
# with:
# action: actions/cache/save@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
# with: |
# path: mutation-testing/packages-output
# key: mutants-stable-develop
# attempt_limit: 5
# attempt_delay: 3000

# # Upload stable output version
# stable-mutants:
# name: Upload Stable Mutants Testing
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# with:
# fetch-depth: 0 # do we want to fetch all?
# - name: Archive mutants output
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: mutants-stable-develop
# path: mutation-testing/packages-output

# ## Mutants testing: Execute on PR on packages that have tested functions modified
# ### download it && see how it is
# incremental-mutants:
# name: Incremental Mutants Testing
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - name: Download stable output artifact
# uses: actions/download-artifact@v3
# with:
# name: mutants-stable-develop
# path: mutation-testing/packages-output
# - name: Display structure of downloaded files
# run: ls -R
# working-directory: mutation-testing/packages-output
# - run: cargo install cargo-mutants
# - name: Update stable mutants with modified functions
# run: ./git-diff.sh
# working-directory: mutation-testing/scripts
# - name: Archive mutants output
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: mutants-stable-develop
# path: mutation-testing/packages-output

# incremental-mutants-2:
# name: Incremental Mutants Testing
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3

# - name: Check for the existence of the stable output artifact
# id: check-artifact
# uses: actions/github-script@v5
# with:
# script: |
# const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
# owner: context.repo.owner,
# repo: context.repo.repo,
# run_id: context.runId,
# });
# const artifactExists = artifacts.data.artifacts.some(artifact => artifact.name === 'mutants-stable-develop');
# core.setOutput('exists', artifactExists);

# - name: Download stable output artifact
# if: steps.check-artifact.outputs.exists == 'true'
# uses: actions/download-artifact@v3
# with:
# name: mutants-stable-develop
# path: mutation-testing/packages-output

# - name: Display structure of downloaded files
# if: steps.check-artifact.outputs.exists == 'true'
# run: ls -R
# working-directory: mutation-testing/packages-output

# - run: cargo install cargo-mutants

# - name: Update stable mutants with modified functions
# if: steps.check-artifact.outputs.exists == 'true'
# run: ./git-diff.sh
# working-directory: mutation-testing/scripts

# - name: Archive mutants output
# uses: actions/upload-artifact@v3
# if: always()
# with:
# name: mutants-stable-develop
# path: mutation-testing/packages-output
Loading
Loading